如何从 Kynetx 电子邮件端点访问消息正文?

发布于 2024-10-08 05:19:02 字数 658 浏览 0 评论 0原文

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

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

I want to extract a URL from an inbound email message and then http:get() the 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 goes in the PRE block, given the following email message:

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

http://www.example.net

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

╭ゆ眷念 2024-10-15 05:19:02

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

要访问电子邮件,您首先从 msg 事件参数中提取电子邮件(采用 RFC822 形式),如下所示:

envelope = event:param("msg");

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

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

在不传递 mime 过滤器的情况下调用 email:parts(envelope) 将返回包含电子邮件所有部分的结构。

获得正文后,您可以使用 textportion.extract(re//) 从电子邮件正文中提取信息。

You use the email:parts() method to extract the portions of the email. In a multipart email, you will have both text/html and text/plain parts.

To access the email, you first extract the email (in RFC822 form) from the msg event param, like so:

envelope = event:param("msg");

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

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

Calling email:parts(envelope) without passing a mime filter will return a struct with all the parts of the email.

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文