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 

services/data/v43.0/sobjects/Document/

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) 
Hi,

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>.content.force.com/servlet/servlet.ImageServer?id=<document_id>&oid=<organization_id>" width="200" height="200"/>
>
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[]{'abc@gamil.com'});

Refer below links.

https://salesforce.stackexchange.com/questions/46663/how-to-add-the-logo-in-email-body
 
https://help.salesforce.com/articleView?id=Why-images-stored-as-static-resources-cannot-be-seen-in-emails-sent-using-VF-email-templates-1327108316482&language=en_US&type=1
 
Please mark it as solved if my reply was helpful, it will make it available
for others as a proper solution.

Best Regards,
​Sandhya