仅从电子邮件中检索新消息
我正在尝试使用 Imaplib 从电子邮件地址检索消息,到目前为止我已经能够检索消息,但是,我只对原始消息感兴趣,这意味着如果消息是“Re:”,那么我不'不想要以前的消息,我只想要新的消息,这可能吗?
这是我从 python 得到的:
test # 10\r\n\r\nOn Thu, Dec 1, 2011 at 11:17 PM, paulo alvarado\r\n<[email protected]>wrote:\r\n\r\n> test # 9\r\n>\r\n>\r\n> On Thu, Dec 1, 2011 at 11:15 PM, paulo alvarado <[email protected]\r\n> > wrote:\r\n>\r\n>> test # 8\r\n>>\r\n>>\r\n>> On Thu, Dec 1, 2011 at 11:14 PM, paulo alvarado <\r\n>> [email protected]> wrote:\r\n>>\r\n>>> test # 7\r\n>>>\r\n>>> On Thu, Dec 1, 2011 at 10:36 PM, paulo alvarado <\r\n>>> [email protected]> wrote:\r\n>>>\r\n>>>> test # 6\r\n>>>>\r\n>>>>\r\n>>>> On Thu, Dec 1, 2011 at 10:36 PM, paulo alvarado <\r\n>>>> [email protected]> wrote:\r\n>>>>\r\n>>>>> test # 5\r\n>>>>>\r\n>>>>>\r\n>>>>> On Thu, Dec 1, 2011 at 9:46 PM, paulo alvarado <\r\n>>>>> [email protected]> wrote:\r\n>>>>>\r\n>>>>>> this is test # 4\r\n>>>>>>\r\n>>>>>>\r\n>>>>>>\r\n>>>>>> On Thu, Dec 1, 2011 at 7:13 PM, paulo alvarado <\r\n>>>>>> [email protected]> wrote:\r\n>>>>>>\r\n>>>>>>> this is test # 1\r\n>>>>>>>\r\n>>>>>>\r\n>>>>>>\r\n>>>>>\r\n>>>>\r\n>>>\r\n>>\r\n>\r\n
正如你所看到的,测试 #10 是新消息,其他内容是之前的回复 我正在使用 python2.7
编辑
我有一个票证应用程序,所以基本上,我希望用户能够通过电子邮件提交票证,所以用户的电子邮件是作者,主题是标题,消息正文是描述,除了如何处理回复之外,我一切正常,因为此时,如果用户通过电子邮件回复,票证的描述将不仅包含新问题(或响应)但它也会包含以前的,所以我想知道是否有办法删除以前的回复并只保留新的回复,这是我的问题的图片。
I am trying to retrieve messages from an email address using Imaplib, so far i have been able to retrieve the messages, however, i am only interested in the original message, meaning that if the message is a "Re:" then i don't want the previous messages, i want only the new one, is this possible ?
heres what i get from python :
test # 10\r\n\r\nOn Thu, Dec 1, 2011 at 11:17 PM, paulo alvarado\r\n<[email protected]>wrote:\r\n\r\n> test # 9\r\n>\r\n>\r\n> On Thu, Dec 1, 2011 at 11:15 PM, paulo alvarado <[email protected]\r\n> > wrote:\r\n>\r\n>> test # 8\r\n>>\r\n>>\r\n>> On Thu, Dec 1, 2011 at 11:14 PM, paulo alvarado <\r\n>> [email protected]> wrote:\r\n>>\r\n>>> test # 7\r\n>>>\r\n>>> On Thu, Dec 1, 2011 at 10:36 PM, paulo alvarado <\r\n>>> [email protected]> wrote:\r\n>>>\r\n>>>> test # 6\r\n>>>>\r\n>>>>\r\n>>>> On Thu, Dec 1, 2011 at 10:36 PM, paulo alvarado <\r\n>>>> [email protected]> wrote:\r\n>>>>\r\n>>>>> test # 5\r\n>>>>>\r\n>>>>>\r\n>>>>> On Thu, Dec 1, 2011 at 9:46 PM, paulo alvarado <\r\n>>>>> [email protected]> wrote:\r\n>>>>>\r\n>>>>>> this is test # 4\r\n>>>>>>\r\n>>>>>>\r\n>>>>>>\r\n>>>>>> On Thu, Dec 1, 2011 at 7:13 PM, paulo alvarado <\r\n>>>>>> [email protected]> wrote:\r\n>>>>>>\r\n>>>>>>> this is test # 1\r\n>>>>>>>\r\n>>>>>>\r\n>>>>>>\r\n>>>>>\r\n>>>>\r\n>>>\r\n>>\r\n>\r\n
as you can see test #10 is the new message, the other stuff are the previous replies
i am using python2.7
EDIT
I have a ticket application, so basically, i want the user to be able to submit tickets, via email, so the user's email is the author, the subject is the title, and the message body is the description, i have it all working fine except for how to handle a reply, because at this moment, if a user replies via email, the description of the ticket will not only contain the new issue ( or response ) but it will also contain the previous ones, so i want to know if there is a way to remove the previous responses and only keep the new one, heres a picture of my issue.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Google 发现
conn.search(None, '(UNSEEN)')
是代码中的重要部分。Google comes up with
where
conn.search(None, '(UNSEEN)')
is the important piece in the code.