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
SalesforceCrm AccountCRMSalesforceCrm AccountCRM 

Send an email alert format in an sendemail message

Hello ,
Do we have an option to send an email alter format in a Send email message .
As in Email Alert ..we have
Subject Line
To ,From nd CC
Body
In body we give the detailed description etc.
For example :I would like to send an email to the customer regarding an product .
So how can i get it formatted in an sendemail message .
Any example very much appreciated.

 
Atul GuptaAtul Gupta
Yes you can do that, you can set HTML as the email body like this
 
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
email.setOrgWideEmailAddressId('0D270000000Kzn1');
email.setTargetObjectId('00570000001ZA7P');
email.setSubject('Test message');
email.setHtmlBody('<html><body><p>Some text</p><hr /><p>Some other text</p></body></html>');
email.setPlainTextBody('Test body');
email.setSaveAsActivity(false);
Messaging.sendEmail(new List<Messaging.Email> { email });