Questions bout internetAddress format.
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Pothios_Machera
Posted On:   Wednesday, March 31, 2004 06:36 AM

Hi, im having some problems with multiple sending. I have a method public ArrayList getAllEmails() which returns a list of emails, but i cant pass it into the postMail method since the recipients is in a array form. I tried changing recipients into a arraylist form but the compiler error states that internetAddress doesnt take in arraylist. Can anyone help pls? Below is my following codes... public void postMail( String recipients[ ], String subject, String message , String from) throws MessagingException { //Set the host smtp address ...... ...... // create some properties and get the default Session // create a message ...... ...... // set the from and to address    More>>

Hi, im having some problems with multiple sending. I have a method public ArrayList getAllEmails() which returns a list of emails, but i cant pass it into the postMail method since the recipients is in a array form. I tried changing recipients into a arraylist form but the compiler error states that internetAddress doesnt take in arraylist. Can anyone help pls? Below is my following codes...


public void postMail( String recipients[ ], String subject, String message , String from) throws MessagingException
{
//Set the host smtp address
......
......
// create some properties and get the default Session
// create a message
......
......
// set the from and to address
InternetAddress addressFrom = new InternetAddress(from);
msg.setFrom(addressFrom);

InternetAddress[] addressTo = new InternetAddress [recipients.length];
for (int i = 0; i < recipients.length; i++)
{
addressTo[i] = new InternetAddress(recipients[i]);
}
msg.setRecipients(Message.RecipientType.TO, addressTo);

   <<Less

Re: Questions bout internetAddress format.

Posted By:   Kevin_Kwan  
Posted On:   Monday, May 3, 2004 08:02 AM

Use the parse method to parse out email addresses.

e.g.
MESSAGE_TO="emailone@somewhere.com,emailtwo@somewhere.com";

InternetAddress[] address = InternetAddress.parse(MESSAGE_TO);
msg.setRecipients(Message.RecipientType.TO, address);
About | Sitemap | Contact