We’ve developed some resources to help you work effectively from home during COVID-19 Click to learn more

Parse mail with script

I am looking at a case where a customer wants to parse incoming mail to a Service mailbox and extract certain information to populate custom fields with and to do a few other things. This should be doable with script I have been told. So now I am playing around with it a bit myself but can't really find how to access the actual mail.

So, how do I access the actual content of the incoming mail?

RE: Parse mail with script

Hi,

There are several different ways of accomplishing this, if you are looking into email filter with script you have access to some variables directly in your script:
(accessible with getVariable):

  • messageId
  • ticketId
  • customerId
  • customerEmail
  • mailBackup
  • isNewCustomer

So you can create a script that does;

Message message;
message.load(getVariable("messageId").toInteger());

String contents = message.getValue("body"); //PlainText is easier to parse

//Get information from contents and do you magic
Von: Michel Krohn-Dale 29. Jun 2020

RE: Parse mail with script

Thanks Michel! That was easier than I tought :)

Von: Patrik Larsson 29. Jun 2020