You need to sign in to do that
Don't have an account?
Image is not displaying in the email Notification trigger
Hi I have written a email Notification trigger. Image is not displaying in the mail that is company logo.
Please find the below code for more info.
trigger sendemailwithattachment on opportunity (after insert,after update){
for(opportunity oppr : Trigger.new){
System.debug('--------------------'+oppr );
if(oppr.Record_Type_Name__c=='Recors type1'){
if(oppr.StageName=='Closed Won'){
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[] {'test@gmail.com'};
mail.setToAddresses(toAddresses);
string htmlHeader = '<html><head>'
+'<body><table>'
+'<apex:image src="{!$Resource.Logo}" width="100" height="70" align="right"/>'
+'<tr><hr width="800" color="red" height="10"/></tr>'
+' </table></head></body></html>';
string htmlbody='contract completion:' +Oppr.Name;
mail.setHtmlBody(
htmlHeader+htmlbody);
//Set email file attachments
List<Messaging.Emailfileattachment> fileAttachments = new List<Messaging.Emailfileattachment>();
for (Attachment a : [select Name, Body, BodyLength from Attachment where ParentId = :oppr.Id]){
// Add to attachment file list
Messaging.Emailfileattachment efa = new Messaging.Emailfileattachment();
efa.setFileName(a.Name);
efa.setBody(a.Body);
fileAttachments.add(efa);
}
mail.setFileAttachments(fileAttachments);
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}
}
}
}
Hi Chiranth,
Just refer this link and use the Html tag instead of <apex>
Hope this will work for you.
http://www.shellblack.com/salesforce/sales-cloud/html-email/
Thanks
Anil.B