• 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

jsp&java mail :How to send email to multiple users ?

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am working on a tool taht sends email to customers.i am using
Java Mail API..The below artical had helped me in that .
http://www.jspinsider.com/tutorials/jsp/javamail/JSPJavaMail_intro.html
Basically i am interested in sending email to multiple user.Could any one help me in this issue..of sending email to multiple users
if possible a Snippet of code ..
Thanks
Mohan
------------------
 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
MimeMessage message = new MimeMessage( session ) // put your own Session object here
String toAddresses = " someone@company.com, someoneelse@othercompany.net";
message.setRecipients( Message.RecipientType.TO, toAddresses );
The second parameter that the method setRecipients takes is a string of one or more e-mail addresses delimited by commas.
 
vijayinukollu
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Thanks for you'r information..
here in my Case ...the "toAddress" is dynamically generated from the database..i mean the email address are been retrived form the database,so some times it may be 2 or 10...so how to make this dynamic increment of the email address to the "toAddress" piece which you specified in you'r code ?
Hope you got my problem ?
Thanks
Mohan
 
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by vijayinukollu:
Hi,
so how to make this dynamic increment of the email address to the "toAddress" piece which you specified in you'r code ?
Thanks
Mohan


A general answer; put it into an ArrayList which has a dynamic size but not the same overhead as a Vector, convert it to an array if you wish, and iterate through it one way or another, sending to each address. The InternetAddress Class also has a public static InternetAddress[] parse(String addressList) method that converts a comma separated string of addresses into an array of InternetAddress objects.
Appearantly there is a setRecipients method that takes an array of Address instead of a single Address which is a variation of the method that I believe greg was suggesting.
 
reply
    Bookmark Topic Watch Topic
  • New Topic