• Post Reply Bookmark Topic Watch Topic
  • New Topic

Unable to send mail to multiple receipients....

 
Jigar Naik
Ranch Hand
Posts: 762
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to send mail to multiple receipient by seperating TO using comma or semicolon but i'm getting the following error...

16:31:12,215 ERROR [STDERR] javax.mail.internet.AddressException: Illegal address in string ``naikjigar@hotmail.com,naik83@gmail.com''

any idea on multiple receipients ???
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to add all addresses one by one - you can't use a concatenated string like that.
 
Jigar Naik
Ranch Hand
Posts: 762
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ya but there is another method addReceipients(which takes InternetAddress[]) as arg how do i use that one ?
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With a little bit of thought and/or use of the javadocs it should be easy to figure out how that method works. If not, post back here, and we'll give you a hint.
 
Jigar Naik
Ranch Hand
Posts: 762
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i did this

String[] result = TO.split(",");

now i need to convert String [] to Address[]

but not getting any idea...
 
Jigar Naik
Ranch Hand
Posts: 762
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you were right...all i needed is to see api

i did it
msg.addRecipients(Message.RecipientType.TO,(InternetAddress.parse(TO)));
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!