You need to sign in to do that
Don't have an account?

MassEmailMessage using setTemplateId NEED URGENT HELP
When using setTemplateId with mass email, how to pass a record ID to the template to show all the merge fields. I have a mass email apex class and it does send the email but all the merge fields are blank. Please help.
You need to specify "targetObjectId" for your email template, which is the contact, lead or user which the email goes to and also is used to merge the fields from. Also, if you have other objects that you need to merge fields from and the "targetObjectId" is a contact, then you can specify "whatId" to reference the other related object to merge fields from. Have a look at the documentation. (https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_email_outbound_single.htm#apex_Messaging_SingleEmailMessage_setTargetObjectId)