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
Chris RosasChris Rosas 

Getting merge field to work in custom email template??

Hi,

I'm having trouble getting a field to populate correctly in my template.  I must use a Custom template (I'm left justifying the entire email, not centered email like SFDC does OOB.  I'm also making the email appear widescreeen like normal emails does.  I've already figured all of that part out.).  So this means I need to create my template via actual HTML code, not the WYSIWYG interface SFDC provides in the HTML email template editor.  

I'm simply trying to have the first name of the contact come up, so I can send out "personalized" emails to a broad group of people.  My current code looks like this:  </font><p style="margin: 0in 0in 0pt;"><span style="color: black;"><font face="Arial, sans-serif">Hi {!Contact.FirstName},</font></span></p><font face="Arial, sans-serif">

When I test the email, it looks great, OTHER than coming up "Hi {!Contact.FirstName},".  My goal is to have it come up "Hi Bob," (Bob being replaced by whatever name is in the contact record I'm sending to).   My question: what specifically do I need to change in that line of code to have it pull the contact name from the SFDC record?  How do I get the merge to work? 

Thanks!!
 
Naval Sharma4Naval Sharma4
Hi Chris,

If you are using this email templalte with Workflow then you have to create workflow on Contact object. If you are using apex code to send this email using Messaging.SingleEmailMessage then you have to set target object id that will be contact id in your case.

Do let me know if you need more help.

Thanks,
Naval
Michael Adrian AlcazarMichael Adrian Alcazar
Hi Chris, 

I Tried to use the code that you provided and confirm that its working (for the merge field part) 

Only thing that I can thing of on why it shows "Hi {!Contact.FirstName}," is.

- If your using the Send Test and Verify merge field, Make sure that you put a contact on the "Recipient Record:" part

Hope this helps ^_^