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

Visualforce - Email Templates - Merge Fields - Cross Fields

This is my trigger code:
    if(trigger.isAfter && trigger.isInsert){
        List<Messaging.SingleEmailMessage> emails = new List<Messaging.SingleEmailMessage>();
        EmailTemplate emtemp = [SELECT Id from EmailTemplate WHERE Name = 'Email Notification'];
        System.debug('em temp'+emtemp);
        for (EM_Event_Team_Member_vod__c addedmem : {
            Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
            email.saveAsActivity = false;
This is the email template:
<messaging:emailTemplate subject="Addition of Team Member" relatedToType="EM_Event_Team_Member_vod__c">
<messaging:HTMLEmailBody >
Hi {!relatedTo.Event_vod__r.Name},
Event Name: {!relatedTo.Event_vod__r.Name}<br/>
Event City: {!relatedTo.Event_vod__r.City_vod__c}<br/>
Event Start Time : {!relatedTo.Event_vod__r.Start_Time_vod__c}<br/>
Event URL :

And this is the email i received:
Hi ,

Event Name:
Event City:
Event Start Time :
Event URL :

Please help me how to get values populated in the email.
Soyab HussainSoyab Hussain
Hi Hitesh,

You are getting blank values because in your email the parent record is blank i.e. Event_vod__e doesn't have any value.

In order to resolve your issue please follow :
Fill the values in the parent so that the email template can fetch them and populate.

If you found it useful please appreciate my efforts and mark it as the best answer.