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
ClintLeeClintLee 

Email Services - Possible to determine if an Incoming Email is HTML or Plain Text?

Hello,

 

I have spent some time searching the forums and reviewing the docs on Email Services and cannot find an answer to this, so I'm hoping the smart folks here can help me out.

 

I have an email service set up that accepts incoming emails.  Is there a way to check an incoming email to determine whether it is in HTML or PlainText format?

 

For example, something like this:

 

if (email is in HTML format) {

   do this code using email.htmlBody;

 

} else {

   do this code using email.plainTextBody;

}

 

Thanks in advance,

 

Clint

 

paul-lmipaul-lmi

spec for HTML email is to also include plaintext, so it may just be as simple as

 

if (htmlbody == '' || htmlbody == null){ type = 'plaintext';}

 

the email message handling will expose plain text and html properties, so all you need to bring is your own comparision logic to determine each.

 

Since HTML emails should also include a plain text version, I'd recommend having your logic look for the HTML version, rather than the plain text.

 

Check teh documentation for how to access plaintextbody and htmlbody.