You need to sign in to do that
Don't have an account?
Thomasm
Trigger to send email with template
I have a trigger that is sent everytime a custom object record is created usind email services. It works like an auto response so the person does not have to be a contact. It currently works and brings in the merge field from the template but the graphics are not there and nothing show in outlook.
here is my code
trigger EmailNotify on Service_Call_Log__c (after insert) {
for(service_call_log__C b: trigger.new){
EmailTemplate template = [SELECT Id, Subject, HtmlValue, Body FROM EmailTemplate WHERE Name = 'Case Created Service Call Log'];
//Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
// mail.setTemplateId(template.id);
String subject = template.Subject;
subject = subject.replace('{!Case.Account}', 'Your Case has been created');
String htmlBody = template.HtmlValue;
htmlBody = htmlBody.replace('{!Service_Call_Log__c.Subject__c}', b.subject__C);
htmlBody = htmlBody.replace('{!Service_Call_Log__c.Description__c}', b.Description__c);
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setSubject(subject);
mail.setHtmlBody(htmlBody);
mail.setToAddresses(new String[] {b.web_email__C});
mail.setSenderDisplayName('SFDC Developer');
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}
}
here is my code
trigger EmailNotify on Service_Call_Log__c (after insert) {
for(service_call_log__C b: trigger.new){
EmailTemplate template = [SELECT Id, Subject, HtmlValue, Body FROM EmailTemplate WHERE Name = 'Case Created Service Call Log'];
//Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
// mail.setTemplateId(template.id);
String subject = template.Subject;
subject = subject.replace('{!Case.Account}', 'Your Case has been created');
String htmlBody = template.HtmlValue;
htmlBody = htmlBody.replace('{!Service_Call_Log__c.Subject__c}', b.subject__C);
htmlBody = htmlBody.replace('{!Service_Call_Log__c.Description__c}', b.Description__c);
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setSubject(subject);
mail.setHtmlBody(htmlBody);
mail.setToAddresses(new String[] {b.web_email__C});
mail.setSenderDisplayName('SFDC Developer');
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}
}
If the issue is with all email clients, please review the below article and blog post which explains how you can send emails with images
http://help.salesforce.com/apex/HTViewSolution?id=000086448&language=en_US
http://salesforce.stackexchange.com/questions/21706/images-not-showing-up-in-email-sent-using-email-template