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
ZfactorForceZfactorForce 

PlainTextEmailBody within Email Service

Hi,
The issue I am having here is if the email is coming in HTMLBody my email service states the Body is null... I use the
 myPlainText = email.plainTextBody;
If it is HTML then it does not work... it comes as null...
Anyone else run into this problem, any solutions?
Z
Best Answer chosen by ZfactorForce
SalesFORCE_enFORCErSalesFORCE_enFORCEr
For HTML emails use email.htmlBody

All Answers

SalesFORCE_enFORCErSalesFORCE_enFORCEr
For HTML emails use email.htmlBody
This was selected as the best answer
ZfactorForceZfactorForce
Hmmm question now the comments that come from HTML Body has the HTML sysntax for example:

<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style id="owaParaStyle" type="text/css">P {margin-top:0;margin-bottom:0;}</style>
</head>
<body ocsi="0" fpstyle="1">
now testing HTML body last time<br>


How do i get rid of the syntax tags? just have the body text.
thanks
Z
SalesFORCE_enFORCErSalesFORCE_enFORCEr
Just use a regex similar to ('<[^>]+>') and do string.replaceAlll