• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java Mail - How to send to Multiple recipients

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey was wondering if anybody could help me i'm trying to set up javamail so that i can send out mailing lists from my website, here's the code i have what do i need to change???
<%@ page import="java.util.*, javax.mail.*, javax.mail.internet.*" %>
<%
Properties props = new Properties();
props.put("mail.smtp.host", "hoth.compsoc.com");
Session s = Session.getInstance(props,null);
MimeMessage message = new MimeMessage(s);
InternetAddress from = new InternetAddress("sanz@eircom.net");
message.setFrom(from);
//String toAddress = request.getParameter("to");
//InternetAddress to = new InternetAddress(toAddress);
//message.addRecipient(Message.RecipientType.TO, to);
String strName = /* request.getParameter("to"); */
InternetAddress[] address = InternetAddress.parse(strName);
message.setRecipients(Message.RecipientType.TO, address);
String subject = request.getParameter("subject");
message.setSubject(subject);
String text = request.getParameter("text");
message.setText(text);
Transport.send(message);
%>
<html>
<p align="center">The Message has been sent.<br>Check your inbox.</p>
<p align="center"><a href="Mail.html">Click here to send another!</a></p>
</html>

Thanks a mill
Sanz
 
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use the addRecipients() method of the MimeMessage class, where you can set any number of addresses.
Just create an array of InternetAddress and set it as recipient of your message:


HTH
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic