abughali.com IT and Business Blog by Mahmoud Abu-Ghali

20Feb/100

Javamail: Sending to multiple recipients

The following code snippet demonstrates how you can send to multiple recipients from java :

 String toList = "email1@emailserver.com,email2@emailserver.com" ;
 String to [] = to.split(",");        
 
 InternetAddress[] addresses = new InternetAddress[to.length];
 
 for (int i = 0; i < to.length; i++)
    addresses[i] = new InternetAddress(to[i]);
 
 msg.setRecipients(Message.RecipientType.TO, addresses);
Filed under: Java Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


Spam protection by WP Captcha-Free

No trackbacks yet.