Query the email header variables

Hi

Anybody know if we have access to the email header variables. I would to be able to query the X-MS-Exchange-CrossTenant-ID

Thank you

Richard

Hi @Richard ,

Yes, you have full access to them as {{email.headers.something}}.

Can you tell me more about what you are building?

This will get you the value as “xxxxxx-xxxxxx-xxx-xxxxxxx”:
{{json_encode email.headers.[x-ms-exchange-crosstenant-network-message-id]}}

You’ll just have to pull the value out from between the double quotes.

Thank you, I have some Microsoft alert email notification where we cannot identify the organisation to assign to the correct Autotask account.

That’s a great use case! Create a rule for emails from Microsoft that contain a cross-tenant header. In the rule, lookup the account based on that cross-tenant header and create a ticket for the correct account.

Genius!

Hi @travis

Oddly my client give me the suggestion. Don’t need to added any message rules in exchange. Just added UDF field to storing the information.

Having some issues with the works flow.

Using the json example {{json_encode email.headers.[x-ms-exchange-crosstenant-network-message-id]}} as a base.

When the workflow is running the string is returning

But struggling writing the query.

When I query the account UDF field I am getting the following results

I think the rendered string is returning an array and don’t know how to use element one of the array.

Thank you

Can you send me the URL to the history records so I can see the full context? That will help me be sure I answer accurately.

Hi @travis

Thank you, history MSPintegrations
Thank you

@Richard

Perfect.

Here’s the email.headers properties for that history. You can see the tenant id is an array of two values (it’s the same value twice, but still an array of two items):

image

Instead of using {{json_encode ...}} to encode them both, I would access just the first item without json_encode. Change your first step from this:

{{json_encode email.headers.[x-ms-exchange-crosstenant-id]}}

to this:

{{email.headers.[x-ms-exchange-crosstenant-id].[0]}}

Then, your query to Autotask will query just for the string, and not for a JSON-encoded array of two strings.

Let us know how it goes!