You need to sign in to do that
Don't have an account?
lovetolearn
toAddresses for MassEmailMessage class
Hi,
I see that there is not setToAddressses method for the MassEmailMessage class like there is for SingleEmailMessage. Is there then any way to specify the recipicent's email address for mass emails?
Thanks in advance.
This is why it is different from singleemail message. Why can't you make you of ID's of the respective object to send an email using MassEmail.
I tried that, but I was unable to specify the recipient's email address.
its not required to explicity specify the email address when you are using the mass email...the object id itself is enough to pick up the email field of the respective user like below
Messaging.MassEmailMessage mail = new Messaging.MassEmailMessage();
mail.saveAsActivity = false;
mail.setTargetObjectIds(mailToIds);///Here mailToids are contact ids in my scenario....
mail.setTemplateId(e.Id);
mail.setUseSignature(false);
mail.setSaveAsActivity(false);
// Send the email
Messaging.sendEmail(new Messaging.MassEmailMessage[] { mail });