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
Ryan McNeely 1Ryan McNeely 1 


I simply want my company's logo to appear at the top of my Messaging.SingleEmailMessage
I tried referring to it as a Static Resource. It seems this is not possible in Apex.
So I tried saving the logo as a document and referencing it via Document.Body
This did not work though.

Please advise :)
global static String buildMessageBody(String firstname, String bugName, String caseNumber, Boolean display) {
                String messageBody = '<html><body>';
        		messageBody = '<div style="margin: -40px 0px -20px 30px;"><img src="/services/data/v43.0/sobjects/Document/0152D000000xxxxxAG/Body" alt="abc" width="178" height="27" /></div>';  
        		messageBody += '<p>Great news! ' + bugName + ' has been fixed. This bug relates to your Support Ticket: ' + caseNumber +'.</p>';
        		messageBody += 'Thank you<br/>';                
                        messageBody += '</body></html>';
			return messageBody;

SandhyaSandhya (Salesforce Developers) 

Refer below sample code
String subject     = '';
String body        = '';          
String logo        = '';  
subject ='Remainder Email';
body ='<html><body style="font-family: arial; font-size: 12pt;"><image id="Logo" src="<apex:image id="theImage" value="https://c.<instance><document_id>&oid=<organization_id>" width="200" height="200"/>
Dear Customer, <br><br>Thank for Ordering';

Messaging.SingleEmailMessage conformemail = NEW Messaging.SingleEmailMessage();
conformemail.setToAddresses(NEW String[]{ord.Order_status_email__c});            
Messaging.sendEmail(NEW Messaging.SingleEmailMessage[]{''});

Refer below links.
Please mark it as solved if my reply was helpful, it will make it available
for others as a proper solution.

Best Regards,