![]() |
![]() | #1 |
vse naoborot... Join Date: 03 2004 Location: Yerevan Age: 38
Posts: 97
Downloads: 0 Uploads: 0
Reputation: 0 | 0 | ![]()
Ya navichek v Java i u menya takoy vopros: kak ya mogu iz Java sgenerirovat' outlook mail, s imeushimisya dannimi: e-mail address-om i attachment-om.. pojaluysta posovetuyte gde ya mogu nayti informaciu o classax, kotorie ispol'zuyutsya v reshenii takogo roda zadach' (dumayu, chto takie classi doljni imetsya ![]() ![]()
__________________ Poskol'ku mi jivem v sumasshedshem mire, nam samim nujno bit' nemnogo sumasshedshimi! ![]() http://vsdi.net/count/down/i/meter-ru32783.png |
![]() |
![]() | #2 |
Угадай Join Date: 01 2005 Location: Armenia, Yerevan Age: 44
Posts: 12
Downloads: 0 Uploads: 0
Reputation: 0 | 0 | ![]()
Прив Katy, ниже приведенный код думаю поможет ![]() Код демонстрирует как отправлять маилики с аттачами используя SMTP компоненты Code: import com.jscape.inet.smtp.*; import com.jscape.inet.mime.*; import com.jscape.inet.email.*; import java.io.*; public class SmtpAttachmentExample extends SmtpAdapter { public void sendMessage(String hostname, String to, String from, String subject, String body, String attachment) throws SmtpException, IOException, MimeException { // create new Smtp instance Smtp smtp = new Smtp(hostname); // enable debugging smtp.setDebug(true); // register this class to capture SMTP related events smtp.addSmtpListener(this); // connect to SMTP server smtp.connect(); // create email message EmailMessage email = new EmailMessage(); email.setTo(to); email.setFrom(from); email.setSubject(subject); email.setBody(body); // add attachment to email message email.addAttachment(new Attachment(new File(attachment))); // send email message smtp.send(email); // disconnect from SMTP server smtp.disconnect(); } // capture connect event public void connected(SmtpConnectedEvent evt) { System.out.println("Connected to SMTP server: " + evt.getHostname()); } // capture disconnect event public void disconnected(SmtpDisconnectedEvent evt) { System.out.println("Disconnected from SMTP server: " + evt.getHostname()); } public static void main(String[] args) { String hostname; String to; String from; String subject; String body; String attach; try { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); System.out.print("Enter SMTP hostname (e.g. mail.domain.com): "); hostname = reader.readLine(); System.out.print("Enter To address (e.g. [email protected]): "); to = reader.readLine(); System.out.print("Enter From address (e.g. [email protected]): "); from = reader.readLine(); subject = "iNet Factory Attachment Example"; body = "see attached image"; attach = "image.gif"; SmtpAttachmentExample example = new SmtpAttachmentExample(); example.sendMessage(hostname,to,from,subject,body,attach); } catch(Exception e) { e.printStackTrace(); } } } |
![]() |
![]() | #3 |
Угадай Join Date: 01 2005 Location: Armenia, Yerevan Age: 44
Posts: 12
Downloads: 0 Uploads: 0
Reputation: 0 | 0 | ![]()
код который я привел думаю что не сработает у тебя (используется спецефическая библиотека), так что в добавок pdf file который детально рассматривает классы и библиотеки для отправки и получения майлов и с аттаяами и без них, которые есть в свободно распростроняющемся J2EE пакете. Так что дерзай :Ճ
Last edited by Smile; 07.02.2005 at 12:46. |
![]() |