I had some other idea to do this. <code> EmailTemplate template = [ SELECT Id, Name, Subject, Body, HtmlValue FROM EmailTemplate WHERE Name = 'My Name']; templateId = template.Id; Custom_Object__c obj = [ SELECT Name, Custom_Field_1__c, Custom_Field_2__c FROM Custom_Object__c WHERE Id = :my.Id]; Map<String, String> data = new Map<String, String>(); for ( String key : new List<String>{'Name', 'Custom_Field_1__c', 'Custom_Field_2__c' } ) { data.put('{!Custom_Object__c.' + key + '}', (String) obj.get(key) ); System.debug( LoggingLevel.ERROR,'@@@ key : ' + key ); System.debug( LoggingLevel.ERROR,'@@@ obj.get(key) : ' + obj.get(key) ); } data.put('User.FirstName', UserInfo.getFirstName() ); data.put('User.LastName', UserInfo.getLastName() ); String body = template.HtmlValue; System.debug( LoggingLevel.ERROR, body); System.debug( LoggingLevel.ERROR,'@@@ template.HtmlValue: ' + template.HtmlValue ); System.debug( LoggingLevel.ERROR,'@@@ template.Subject: ' + template.Subject ); String subj = template.Subject; for ( String key : data.keySet() ) { body = body.replace( key, data.get( key ) ); subj = subj.replace( key, data.get( key ) ); } </code>