+ Start a Discussion
Lukesh KarmoreLukesh Karmore 

hii can we use CSS in setHtmlBody in Messaging.singleEmailMessage

hii can we use CSS in setHtmlBody  in Messaging.singleEmailMessage
I  am tryingh it but when send mail Css is not working
thank you
Suraj Tripathi 47Suraj Tripathi 47

Hi Lukesh,

Yes,You can apply the css in setHTMLBody.

Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();
message.settoAddresses(new String[] {'xyz@gmail.com'});
message.setsubject('Test');
message.setHtmlBody('<h1 style="color:red;">Hello</h1>');
Messaging.SingleEmailMessage[] messages =   new List<Messaging.SingleEmailMessage> {message};
Messaging.SendEmailResult[] results = Messaging.sendEmail(messages);

I hope you find the above solution helpful. If it does, please mark it as the Best Answer to help others too.
Thanks and Regards,
Suraj Tripathi