Email-to-Flow, What about those pesky email headers?

Email-to-Flow is available on the Salesforce Appexchange.

If you haven’t gotten a chance to review Introducing Email-To-Flow, a low-code Email Service – Sproket Logic, please do. This will give you a general overview of Email-to-Flow. If you’re up-to-speed, let’s talk about those pesky email headers.

What are email headers anyway?

There is wealth of knowledge available on the web regarding email headers. For this conversation, though, we are going to keep it simple. In addition to the To, From, Subject and Body of an email, an email includes an email header. The header contains information about the email including such items as the Message Id, the authentication, sender information, etc. Email-to-Case leverages information contained within the email headers to link case response emails to their originating case.

Ok, great. But do I need to store Email Headers?

This is typically the crux of the question surrounding email headers in Salesforce. “It’s great knowing email headers provide addition information about emails. I don’t use or need that information. Email headers are eating up my data storage. Can I just remove that data?

It’s a great question. To answer the question, let’s explore what Salesforce absolutely needs from the email header.

Salesforce recently introduced new threading behavior for Email-to-Case. Included in that introduction, a new getCaseIdFromEmailHeaders(headers) apex method was introduced. Simply put, the method leverages the In-Reply-To and References values in the email header to find the originating case. In Email-To-Flow, we use the same method to locate and link the case in the Get Case If From Headers apex action.

So, we need to store email headers for that logic to work?

Not necessarily. As part of the Email-to-Case process, the information required for the origination linking process is extracted and stored in individual fields on the Email Message object. Once extracted, the email header information is not required for threading to work as expected.

Great. We can just remove the email header field?

If you are desperate for data storage, removing the email header information is absolutely an option. If you have no interest or need for the information contained with the email header, it might be a great option. But before you proceed, remember that the email header has a lot of valuable information. You may want to consider some options. For example, you may want to keep email header data until a case is closed.

Nope. Tell us how to get rid of email headers as part of the process.

If you are sure you want to remove email headers on insert, Email-to-Flow gives you some options.

OPTION 1: Just the good stuff

If you take a look at typical email headers, it’s chalk full of data. You might need to waltz over to the IT department to make header or tails of the data. In fact, we recommend discussing email headers with your IT department before making any decisions to remove data. They can help provide details on what information could be valuable in the future.

Once you decide on the good bits, Email-to-Flow provides an apex action to help keep only the email header data you want. In this example, the decision was made to save only 5 key email header values. (NOTE: We recommend that you always keep Message-ID and Thread-Index.) The Email Header Keep Value Custom Metadata Types is populated with those 5 values.

Open the default Email-to-Flow Create Case template. Locate the Shrink Email Header apex action.

In the apex action, set Shrink List to true. This will instruct Email-to-Flow to remove all email headers except those listed in the custom metadata type.

OPTION 2: Remove it all

To save none of the email header data, simple set Purge Header instead.