function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
djbakerman.ax666djbakerman.ax666 

using a custom object in an email template target instead of contact / lead

Hello -

 

I'm attempting to use apex to send an outbound email via apex.  I created a custom object, and one of the fields is an email address.  Is it possible to use the recordId of the custom object as the whatTo object for the setTargetObjectID so that the email field of my custom object is used (and by nature the remaining merge fields of my custom object)?

 

Thanks,


Daniel

Shilpa_SFShilpa_SF

Hi,

 

  As per the Salesforce standard , While sending an outbound email via apex ,the TargetObjectID uses only only Contact,Lead,User. The ID you specify sets the context and ensures that merge fields in the template contain the correct data. You will have to link to any one of the objects mentioned.