Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Duplicate email address

843830Apr 4 2003 — edited May 12 2009
When I send mail to multiple recipients, Email received has duplicate email address.For example, email sent to address abc1@def.com & abc2@def.com , email received has "To address" abc1@def.com, abc2@def.com , abc2@def.com . Second email address onwards gets duplicated. I am using Outlook email client. No problem if email is sent to only one recipient.
.
.
.

Session session = Session.getDefaultInstance(props, null);
javax.mail.Message message = new MimeMessage(session);
fromHost = "test@test.com";
message.setFrom(new InternetAddress(fromHost));
message.setHeader("X-Mailer", "JavaMailer");
message.setSentDate(new Date());
message.setSubject("test");
ArrayList to = new ArrayList();
to.add("abc@def.com");
to.add("efg@def.com");
message.addRecipient(javax.mail.Message.RecipientType.TO,
new InternetAddress("abc1@def.com "));
message.addRecipient(javax.mail.Message.RecipientType.TO,
new InternetAddress("abc2@def.com "));

message.setContent("Hello", "text/plain");
Transport.send(message);

Any help appreciated.


Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 9 2009
Added on Apr 4 2003
5 comments
1,012 views