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
kminevkminev 

TextArea field formatting

HI,

 

I have a TextArea field which stores an email body. When I save it my email body formatting is fine and if I have multiple line I see those. However when I load this field's text from an apex and try to store it to an email and send it it all comes in one line.

 

Is there a way or an option to convert my TextArea value to the formatting that shows on the screen?

 

Thanks in advance.

kminevkminev

Also in addition to the above, when I copy and paste the text from the Apex Explorer to a word document I can see the formatting is fine....so why when I store the email body to an apex string the formatting goes away?

 

Thanks

_Prasu__Prasu_

Email object in the Salesforce has two methods for setting the email body.

 

mail.setPlainTextBody('Your Case: ' + case.Id +' has been created');

mail.setHtmlBody('Your case:<b> ' + case.Id +' </b>has been created<p>'+
' View case <a href=https://na1.salesforce.com/'+case.Id+'>click here</a>');

 did you tried both?

 

kminevkminev

Yes I did try both, however I was trying the setHtmlBody one since I hard-coded my emails as an html formatted, thenk switched to plain text and everything worked.

 

Very strange!