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
NItesh SaxenaNItesh Saxena 

Mail leads with custom object records

Hi Experts,

I have created a custom object which is related to User. One user can have multiple records for the object.

I have created a custom email-template with lead data and custom object data. But when I try to mail a lead, I can select a template but cannot select the custom object record. So the email doesn't get the custom object record.

Can anyone help me out?


Thanks & Regards,

Nitesh Saxena

Nitin PaliwalNitin Paliwal
HI Nitesh,
Unfortunately, while sending an email through apex and using Email Template in that , we cannot allow to set custom objects for mapping the fields and thus values are not reflected in the body of the Email.
There is a workaround :
Either use Workflow to send the EmailAlerts using the EMailTemplate.
Or in the Apex do not use the EMailTemplate rather create your own body dynamically in Apex using a String Variable, and set the HTMLBody of the Email and send the Mail.

I hope this solves your problem.