2

How to add the logo in HTML email body. I have use an apex class that send an notifications to customers.The below code is send an emails to customers **but in email body the image/logo is not displayed**. I am doing correct way or not.Some one can help me.

Note: Email are send to customers but logo is not displayed in the email body.

String subject     = '';
String body        = '';          
String logo        = '';  
subject ='Remainder Email';
body ='<html><body style="font-family: arial; font-size: 12pt;"><image id="Logo" src="https://ap1.salesforce.com/resource/1399298684000/MyLogo"/>
Dear Customer, <br><br>Thank for Ordering';

Messaging.SingleEmailMessage conformemail = NEW Messaging.SingleEmailMessage();
conformemail.setSubject(subject);
conformemail.setHtmlBody(body);                      
conformemail.setToAddresses(NEW String[]{ord.Order_status_email__c});            
Messaging.sendEmail(NEW Messaging.SingleEmailMessage[]{'[email protected]'});

1 Answer 1

3

Ramesh, when displaying images in email you have to use externally accessible url.

the image source url you are using your email body is accessible only for authenticated users in salesforce

src="https://ap1.salesforce.com/resource/1399298684000/MyLogo"/

you have to use a url something like this

https://c.<instance>.content.force.com/servlet/servlet.ImageServer?id=<document_id>&oid=<organization_id

please refer this help article for more details

4
  • Yes you are correct,In my code I have specified dummy url. Actual url is same for you specified. I have tried actual URL but it displayed BLANK Aug 12, 2014 at 12:24
  • did you try opening the image url in a different browser where you are not logged into salesforce ? can you share the image url here pls ? Aug 12, 2014 at 12:27
  • I have tried different browser with out logged in salesforce.It displayed in the browser. Aug 12, 2014 at 12:33
  • I have specify the image height and width now the image is came in email body. Aug 12, 2014 at 14:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .