Skip to main content

Email Body

MSPintegrations parses incoming emails and populates several properties that represent the contents of the email. The plaintext version of the email and the HTML version (with HTML tags removed) are both available. MSPintegrations also extracts email replies and separates them from the quoted email conversation.

These versions of the email body are available using the properties email.body, email.bodyparts, and email.body_stripped.

What is the difference between email.body, email.bodyparts, and email.body_stripped?

Put succinctly, email.body contains the full contents of the email message, email.bodyparts contains the plaintext and html versions of the email, and email.body_stripped breaks apart email.body to separate out the email signature as well as quoted email replies.

When Email2AT parses an incoming email message, it first populates the following three variables:

  • email.bodyparts.plaintext is populated with the plaintext version of an email if the email was sent multipart with a plaintext part, or it is populated with the entire body of the email if it was not sent multi-part. If the email was sent multipart and a plaintext version was not supplied, this variable will remain empty.
  • email.bodyparts.html is populated with the HTML version of an email if the email was sent multipart an HTML part. If no HTML version was supplied (or if the email was not sent multi-part), this variable will remain empty.
  • email.bodyparts.html_to_plaintext is populated with the contents of email.bodyparts.html but with the HTML tags and code removed. If email.bodyparts.html is empty, this variable will remain empty, as well.

Once Email2AT has populated the 3 email.bodyparts variables, Email2AT populates email.body with the contents of email.bodyparts.plaintext. If email.bodyparts.plaintext is empty, but email.bodyparts.html_to_plaintext has a value, then we populate email.body with the contents of email.bodyparts.html_to_plaintext.

In other words, email.body will always contain the plaintext version of the inbound email, unless the email was sent with only an HTML version, in which case email.body will be populated with the HTML version of the email but with the HTML tags removed. Generally speaking, email.body is the first variable to consider when looking for the body of an email message.

Once email.body is populated, Email2AT then attempts to split the email.body text into 3 parts to store in email.body_stripped:

  • If Email2AT can identify a "quoted" portion of an email, it removes the quoted portion and places it in email.body_stripped.quoted. This section is often found in email replies and contains the contents of the message that is being replied to.
  • If Email2AT can identify a signature in the bottom of the email, it removes the signature and places it in email.body_stripped.signature. This section often includes the sender's name, address, phone number, etc.
  • If Email2AT identified a "quoted" or "signature" section, it places the remainder of the message in email.body_stripped.visible. This leaves just the body of the message with no signature and no copies of the previous message(s) quoted in the email. If Email2AT isn't able to identify any sections of the email that are "quoted" or "signature" sections, the entire email will be placed in email.body_stripped.visible. Because of this, it is safe to use email.body_stripped.visible, as it will either contain a cleaned up version of the email or the entire email, and will never remain blank.

Which version should I use?

The most common variable to use is email.body. This variable will contain the full contents of the incoming email.

When creating a workflow to process a reply to an email, it is common to use email.body_stripped.visible, which will contain only the reply and will discard the quoted email.

Sometimes, an outside mail system will send information in the HTML version of the email that is not present in the plaintext version of the email. In this case, it is appropriate to create a special rule that is used for this email sender and use email.bodyparts.html_to_plaintext.