I want to send a message to multiple Recipients using following the method :
message.addRecipient(Message.RecipientType.TO, String arg1);
OR
message.setRecipients(Message.RecipientType.TO,String arg1);
But one confusion is that in second arguement, how to pass multiple addresses like :
message.addRecipient(Message.RecipientType.CC, "[email protected],[email protected],[email protected]");
OR
message.addRecipient(Message.RecipientType.CC, "[email protected];[email protected];[email protected]");
I can send a message using alternate methods too, but want to know the purpose of the above method. If I cant use it(as till now i haven't got any answer for above requirement) then what is the need for this method to be in mail API.
addRecipient(Message.RecipientType.CC, "[email protected],[email protected],[email protected]"); Or message. addRecipient(Message.RecipientType.CC, "[email protected];[email protected];[email protected]"); I can send a message using alternate methods too, but I want to know the purpose of the above method.
You can send a mass email to more than one recipient using the BCC feature. Click the compose box, after composing your message, click on BCC and add all your recipients. This will send the emails to the recipients keeping email addresses hidden from each other.
For smtp you need to have port number, logon email address and in To:"[email protected];[email protected]" …
If you invoke addRecipient
multiple times it will add the given recipient to the list of recipients of the given time (TO, CC, BCC)
For example:
message.addRecipient(Message.RecipientType.CC, InternetAddress.parse("[email protected]")); message.addRecipient(Message.RecipientType.CC, InternetAddress.parse("[email protected]")); message.addRecipient(Message.RecipientType.CC, InternetAddress.parse("[email protected]"));
Will add the 3 addresses to CC
If you wish to add all addresses at once you should use setRecipients
or addRecipients
and provide it with an array of addresses
Address[] cc = new Address[] {InternetAddress.parse("[email protected]"), InternetAddress.parse("[email protected]"), InternetAddress.parse("[email protected]")}; message.addRecipients(Message.RecipientType.CC, cc);
You can also use InternetAddress.parse
to parse a list of addresses
message.addRecipients(Message.RecipientType.CC, InternetAddress.parse("[email protected],[email protected],[email protected]"));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With