How to access the body of a message from a Kynetx email endpoint?

I want to extract the URL from the incoming email, and then the http: get () URL. How can I access the message body?

select when mail received from "(.*)@example.com" setting user pre { /* extract first URL from message */ } http:get(URL); 

So what happens in the PRE block, given the following email:

 From: Example User < user@example.com > To: x202 Endpoint < a101x202@kynetxapps.net > Subject: An interesting URL http://www.example.net 
+4
source share
1 answer

You use the email:parts() method to extract the parts of the letter. In multi-page email you will have both text / html and text / simple parts.

To access your email, first extract the email (in the form of RFC822) from the msg event parameter, for example:

 envelope = event:param("msg"); 

Then you can use the parts method to extract the parts. This code example retrieves a portion of plain email text:

 textportion = email:parts(envelope,"text/plain").pick("$..text/plain"); 

Calling email:parts(envelope) without passing a filter mime returns a structure with all parts of the email.

Once you have the body, you can use textportion.extract(re//) to extract information from the body of the email.

+3
source

Source: https://habr.com/ru/post/1332443/


All Articles