解析传入电子邮件,剥离数据并推入数据库的工具或方法

时间:2021-01-29 00:30:37

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?

有没有人用脚本来解析传入的电子邮件到特定地址,删除数据并将其插入SQL数据库?

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

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

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

姓名:姓氏姓氏身份证号码:nnnnnnn等。

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.

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

1 个解决方案

#1


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. 遍历每封电子邮件

    3. loop through each line in each email
    4. 循环遍历每封电子邮件中的每一行

    5. find each element, one at a time, in incremental order
    6. 按增量顺序逐个查找每个元素

  2. Delete emails from server..

    从服务器删除电子邮件..

#1


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. 遍历每封电子邮件

    3. loop through each line in each email
    4. 循环遍历每封电子邮件中的每一行

    5. find each element, one at a time, in incremental order
    6. 按增量顺序逐个查找每个元素

  2. Delete emails from server..

    从服务器删除电子邮件..