用于解析传入电子邮件、剥离数据并推送到数据库的工具或方法

发布于 2024-07-25 09:06:32 字数 247 浏览 4 评论 0 原文

是否有人使用脚本来解析发送到特定地址的传入电子邮件、删除数据并将其插入 SQL 数据库?

电子邮件将通过 Exchange 2003 服务器传入,并采用已知的固定格式,即

姓名:名字:姓氏 身份证号码:nnnnnnn ETC。 理想情况

下,该解决方案需要在服务器上运行,而不是在客户端上运行。 任何建议表示赞赏。

最初发布在 serverfault 上,但出于脚本角度交叉发布在这里。

has anybody done anything with scripts to parse an incoming e mail to a specific address, strip out the data and insert it into a SQL database?

The e mail would be coming in through exchange 2003 server and would be in a known fixed format, ie

Name: Firstname Surname
ID Number: nnnnnnn
etc.
etc.

Ideally the solution would need to operate on the server and not a client. Any advice appreciated.

Originally posted on serverfault but cross posted here for the scripting angle.

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

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

发布评论

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

评论(1

蓝海似她心 2024-08-01 09:06:34

是的,我有。 你想用这个来实现什么目的?

如果您想知道如何解析它,到目前为止我发现的最简单的方法是为不改变的固定格式构建一个简单的抓取器/模式匹配器。

我通常会迭代电子邮件的每一行,寻找特定的元素/标识符,之后我将如此多的字符读取到变量中,以便将行提交到数据库。

SO:

  1. 下载所有电子邮件

  2. 循环浏览每封电子邮件
  3. 循环浏览每封电子邮件中的每一行
  4. 按增量顺序一次查找一个元素
  5. 从服务器删除电子邮件..

Yes I have. What are you trying to accomplish with this?

If you want to know how to parse it, the easiest way I have found so far is to build a simple scraper/pattern matcher for your fixed format that doesn't change.

I generally have iterated though each line of the email looking for a specific element/identifier, after which i read so many characters to a variable for the row to be committed to the database.

SO:

  1. Download all emails

    1. loop through each email
    2. loop through each line in each email
    3. find each element, one at a time, in incremental order
  2. Delete emails from server..

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