dcsimg
How to send mail to, n number of recipent when n may vary each time?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   pritosh_pandey
Posted On:   Monday, December 22, 2003 02:51 AM

How to send mail to, n number of recipent when n may vary each time?


I can use

InternetAddress[] address = new InternetAddress[]{

new InternetAddress("abc") ,new InternetAddress("xyz")

}


But this is possible only when I know how many ID I have.

If I try to enter IDs separated by comma ',' then it throws illegal address exception.

I want to send mail to multiple recipents.


Thanks.

Re: How to send mail to, n number of recipent when n may vary each time?

Posted By:   Simon_Ablett  
Posted On:   Monday, December 22, 2003 06:37 AM

I use something akin to the following

Properties props = new Properties();
props.put("mail.host", mMailServer);

Session conn = Session.getInstance(props, null);
Message msg = new MimeMessage(conn);

for ( iPos = 0; iPos < arrTo.size(); iPos++ )
{
msg.addRecipient(Message.RecipientType.TO,
new InternetAddress((String) arrTo.get(iPos)));
}

where arrTo is an ArrayList object containing a list of valid email addresses that I have read in from an external source.Hope that this is of help.

Regards.
About | Sitemap | Contact