how to send a javamail message to an email id like
1 posts in topic
Flat View  Flat View

Posted By:   Mangesh_Kulkarni
Posted On:   Thursday, April 27, 2006 10:20 AM

hi all,

i m naive to javamail.


i wanna get some informatio from a html form and build a mail first. later i wanna send it on an email id
it may pop acc or may genral email id

can i send a javamail message directly to a email id

how i can do so?

Re: how to send a javamail message to an email id like

Posted By:   Rad_Sat  
Posted On:   Thursday, April 27, 2006 11:26 AM

Yes you can, you first need activation.jar and mail.jar set in your classpath.

Then your class should have something like,

smtpHost = configData.getEmailSmtpHost();
boolean debug = false;
Properties props = new Properties();
props.put("", smtpHost);
Session session = Session.getDefaultInstance(props, null);
Message msg = new MimeMessage(session);
InternetAddress addressFrom = new InternetAddress(from);
InternetAddress[] addressTo = new InternetAddress[recipients.size()];
for (int i = 0; i < recipients.size(); i++)
addressTo[i] = new InternetAddress((String)recipients.get(i));
msg.setRecipients(Message.RecipientType.TO, addressTo);
msg.setContent(message, "text/plain");
About | Sitemap | Contact