14 Replies to “Visualforce Email Template with Records”

  1. Hi thanks for this article!
    Im trying to get this Email Template in a standart email action in one of my Objects. Until there everything is working fine. But do you know if there is a way to edit this template in an email action? I get an error: This email template content can’t be modified.


    1. You have to go to the template first and edit there. Once the template is updated, come back to the email > properties. You’ll see the option to update the email with the latest changes from the template.

      Hope that’s clear.


  2. Hi,
    I have almost same implementation to display standard and custom object records in Visualforce Email Template.
    relatedToType is Account.
    Standard object = AccountHistory
    Custom object = custom history
    It is working fine when there are records in AccountHistory i.e. records are getting displayed in email.
    But it is failing when there are records in Custom History only, and not in AccountHistory, in this case email is coming as blank.
    Not sure why it is behaving like so.
    Thanks in advance


  3. Absolut fantastic, you made my day!! Before I found your side I was trying everything to pass those attributes from the VF component to the controller but nothing seems to work. I used assignTo with getParameter() etc. etc. but always got a NULL for the
    Then I found your solution and what could I say WOW…. I only had to change the variables and controller from Public to Global and it works.
    In every possible solution I found so far in the net, they use Public nd it didn’t work.
    Thanks a lot man!!!

    Liked by 1 person

  4. Please find my code which is not triggering email.

    Apex class:
    public class acctTemplt
    public Id Traveling_Dependents{get;set;}
    public List getopptys()
    List oppty;
    oppty = [SELECT Dependent__c FROM Traveling_Dependents__c WHERE Travel_Request__c =: Traveling_Dependents];
    return oppty;

    VF Controller:

    Dependent Name


    Email Template:

    Below is the list of Travelling Dependents for your Travel Request {!relatedTo.Name}.



  5. Hi sfdcFanBoy, I was working on same scenario but different objects.
    These two objects are connected with masterdetail relationship with field name “Travel_Request__c”, when I replace Accountid with Travel_Request__c in
    global String accountId{get;set;}
    then I am getting error, can you please help me out for this


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: