How do I efficiently send a bulk mailing, where I want to send mail out to lots of recipients, not all on the same TO/CC/BCC line?

John Zukowski

Get the necessary Transport object and call sendMessage() on it for each message. Be sure to set/change recipients between calls.


Message message = ...;
Transport t = session.getTransport("smtp");
t.connect();

message.setRecipient(
  Message.RecipientType.TO, recipient1);
t.sendMessage(message, recipient1Array);
message.setRecipient(
  Message.RecipientType.TO, recipient2);
t.sendMessage(message, recipient2Array);
message.setRecipient(
  Message.RecipientType.TO, recipient3);
t.sendMessage(message, recipient3Array);

t.close();
0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact