Skip to main content

Posts

Showing posts from January, 2015

Populating merge field in email template while sending mail from apex.

Hi All, You might have come across the issue of populating custom object info in email template dynamically. Suppose you have designed one email template having merge fields of contact object and one custom object. if you will send a mail from apex using singleEmailmessagApi then only contact merge field will be populated.This is an existing behavior of sfdc. How do we overcome this issue?? As we know if we will use setTemplateId method to set email template which we have already designed then we need to use setTargetObjectId method(Mandatory method ).  setTargetObjectId only accept Contact,User and Lead id that is why  those object merge fields will be populated in email template. Now the question is how can we pass custom object id ?. If we are setting contact id in setTargetObjectId  here then we can use another method called   setWhatId ,there we can pass custom object id.That means if we are sending mail to contact mail then we can pass custom obje...