2010-12-17 102 views
4

我想从入站电子邮件消息中提取URL,然后使用http:get()URL。我如何访问邮件正文?如何从Kynetx电子邮件端点访问邮件正文?

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

那么云在PRE块,给下面的电子邮件消息:

From: Example User <[email protected]> 
To: x202 Endpoint <[email protected]> 
Subject: An interesting URL 

http://www.example.net 
+0

+1有一个很好的问题。 – Alex 2010-12-17 07:30:05

回答

3

您使用email:parts()方法提取电子邮件的部分。在多部分电子邮件中,您将拥有text/html和text/plain部分。

要访问电子邮件,则首先从msg事件参数提取电子邮件(RFC822形式),像这样:

envelope = event:param("msg"); 

然后,可以使用部分的方法来提取的部分。此代码示例提取电子邮件的纯文本部分:

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

调用email:parts(envelope)没有通过MIME筛选器将返回一个结构用电子邮件的所有部分。

一旦拥有了正文,您就可以使用textportion.extract(re//)从电子邮件正文提取信息。

+0

+1一个伟大的答案。 – Alex 2010-12-17 07:28:09

+0

谢谢,这太棒了! – 2010-12-17 15:17:52