• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

javamail with to: list repeated

 
sarvan kumar
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi..
I am working on java mail, in which a mail has to be sent to many recipients, mail is sending to all recipients
correctly, but To address list of the multiple recipients are repeated twice in To: address of the ms-outlook.
when i restart the jboss server then To address list of the multiple recipients are not repeated. please give some tips to get the solution


i am using ms-outlook 2003, mail.jar , activation.jar , jboss server 4.2.0

i am using the following code:

ArrayList maillist = new ArrayList();
consider mailist contains 15 email addresses
InternetAddress[] mail_address_TO = new InternetAddress[maillist.size()];
for (int i = 0; i < maillist.size(); i++) {
mail_address_TO[i] = new InternetAddress((String) maillist.get(i));
}
message.addRecipients(Message.RecipientType.TO,mail_address_TO);

Thanks in advance,
K.Saravanan
 
Rob Spoor
Sheriff
Pie
Posts: 20514
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're adding to the recipients list; anything that was there will remain there. Replace addRecipients with setRecipients to overwrite it.
 
sarvan kumar
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Rob, for your reply, i tried with setRecipients also but still i am facing the same issue
 
Paul Clapham
Sheriff
Posts: 20985
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You didn't post the part of your code where you sent the message, presumably adding the recipient list a second time.
 
sarvan kumar
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have used the following code:

ArrayList maillist = new ArrayList();
// consider mailist contains 15 email addresses

InternetAddress[] mail_address_TO = new InternetAddress[maillist.size()];
for (int i = 0; i < maillist.size(); i++) {
mail_address_TO[i] = new InternetAddress((String) maillist.get(i));
}

message.setRecipients(Message.RecipientType.TO,mail_address_TO);
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic