I'm building an email template, and I want to use merge fields from either a Lead or Contact but I also want to use a related record.

I copy the desired merge fields into my template in the web-ui editor, however, when I go to send a test, I select a Contact, but in the drop-down for related records, I don't see the custom object I'm looking for as an available record type to search on. I do see other custom types that I have but don't want to use...?


If I want to build a dynamic URL for a link in the email body with the html editor, and this link is based on some of the merge fields how do I enter them? The html body of the email shows the HTML in the merge fields in the WSIWYG editor for HTML templates. It has a weblink editor - but I'm not sure where to merge the un-encoded email with merge fields, like so...ok I think I found this in the email template in the IDE...!

<a href="{!sObject__c.MergeField__c}">{!sObject.Name}</a>
  • Great questions, but they're unrelated -- I recommend splitting the merge field question into its own question (and checking whether Peter's answer addresses part 1)
    – Benj
    Commented Oct 5, 2012 at 18:08

2 Answers 2


Check the 'Allow Activities' checkbox under the Optional Features section on the custom Object's edit page. If you do not have that checked then the Object won't come up in the Related to Record picklist. I don't recall in which documentation I read that, but I just verified it in my DE. My quick search found this knowledge article.


Regarding your 2nd question, please check my blog post titled 'Dynamically populating custom HTML email template content in Force.com with custom dynamic data using Apex' which uses custom HTML email templates to send email with data populated from both standard object and dynamically computed data. The code referenced in this article uses SingleEmailMessage to send emails. It can take both email addresses of the recipients or the Salesforce Ids (if it's Salesforce user) which doesn't count against the daily limits.

  • If you specify a Contact, doesn't that still count against your daily limit? Commented Sep 5, 2013 at 17:59
  • If you email to contact from the Accounts / Contact page, it is not counted against the limits. But I'm not sure if that will apply to the apex code. I'll edit my reply to remove it. Thanks Phil for catching it. Commented Sep 5, 2013 at 18:40
  • I thought it did count if it was from Apex is all, I could of course be wrong. Commented Sep 6, 2013 at 13:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .