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
Keaton KleinKeaton Klein 

SingleEmailMessage HTML Status

I have 2 triggers which are nearly identical, one sends an email to Leads and the other sends emails to Contacts.  They both work but the HTML Status related list is only populated for the emails sent to Contacts.  When an email is sent to a lead it shows up under activity history but not HTML Status.  It is important to be able to see if/when an email was opened.

I have snippets from both the Lead and Contact triggers so you can see they are nearly identical.  Any thoughts on why HTML Status works for my Contacts but not my Leads?
 
if (combine==true){        
                   	contactlog = mapcontactToUpdate.get(e.id);	
                	mapcontactToUpdate.put(contactlog.id, contactlog);
                    Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                    string etidasstring = a.ezwf__Email_Template_ID__c;
                    emailt = e.Lastname; 
                    mail.setSenderDisplayName(UserInfo.getName());
                    mail.setReplyTo(UserInfo.getUserEmail()); 
                    mail.setTargetObjectId(e.id);
                    mail.setTemplateId(etidasstring);
                    mail.setSaveAsActivity(true); 
                	myEmails.add(mail);	
            }
              if (myEmails.size() > 0)
            {
                       Messaging.sendEmail(myEmails);
            }

if (combine==true){        
                   	Leadlog = mapLeadToUpdate.get(e.id);	
                	mapLeadToUpdate.put(Leadlog.id, Leadlog);
                    Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                    string etidasstring = a.ezwf__Email_Template_ID__c;
                    emailt = e.Lastname; 
                    mail.setSenderDisplayName(UserInfo.getName());
                    mail.setReplyTo(UserInfo.getUserEmail()); 
                    mail.setTargetObjectId(e.id);
                    mail.setTemplateId(etidasstring);
                    mail.setSaveAsActivity(true); 
                	myEmails.add(mail);	
            }
              if (myEmails.size() > 0)
            {
                       Messaging.sendEmail(myEmails);
            }

 
Best Answer chosen by Keaton Klein
ClintLeeClintLee
Are you using two different email templates - one for Leads and one for Contacts?

If so, you should check the Lead email template to ensure that it was created as an HTML template instead of a Text template.
 

All Answers

AmulAmul
Are you using visualforce page email template?
ClintLeeClintLee
Are you using two different email templates - one for Leads and one for Contacts?

If so, you should check the Lead email template to ensure that it was created as an HTML template instead of a Text template.
 
This was selected as the best answer
David ZhuDavid Zhu
What if you add a hard coded lead id in contact trigger? will the activity be shown in lead's html email status related list?
Keaton KleinKeaton Klein
You got it Clint!  The lead template was a Text template.  Thank you everybody for your responses.