![]() | |
| |||||||
| Home | Register | Blogs | FAQ | Members List | Calendar | Downloads | Arcade | Mark Forums Read |
| Web Development Java/PHP/Perl/ASP and more |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 |
| vse naoborot... | 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 ). Zaranee blagodaru ![]() |
| | |
| | #2 |
| Угадай Join Date: Jan 2005 Location: Armenia, Yerevan
Posts: 12
Rep Power: 0 Reputation:
10 | Прив 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. recipient@domain.com): ");
to = reader.readLine();
System.out.print("Enter From address (e.g. sender@domain.com): ");
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: Jan 2005 Location: Armenia, Yerevan
Posts: 12
Rep Power: 0 Reputation:
10 | код который я привел думаю что не сработает у тебя (используется спецефическая библиотека), так что в добавок pdf file который детально рассматривает классы и библиотеки для отправки и получения майлов и с аттаяами и без них, которые есть в свободно распростроняющемся J2EE пакете. Так что дерзай :Ճ
__________________ просто улыбнись Last edited by Smile : Feb 7, 2005 at 11:46. |
| | |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Pomogite :) | Mulik | MusiCity | 13 | Jan 11, 2005 12:17 |
| Pomogite nayti | Mulik | History and Politics | 5 | Aug 22, 2004 05:37 |
| Pomogite pojaluista naiti nazvanie pesni.... | DaNYer | General | 13 | Oct 19, 2002 04:37 |
| pomogite najti Referat pro Mesropa Mashtoca!!!! | _MiLord_ | General | 8 | Sep 19, 2002 22:30 |
| Pomogite nayti knigu plz! | Gayka | Literary nook | 2 | Jul 31, 2002 17:07 |