Parsing forwarded emails

前端 未结 4 1621
半阙折子戏
半阙折子戏 2021-01-11 23:27

I\'m writing some code to parse forwarded emails. What I\'m not sure is if maybe there is some Python library, some RFC I could stick to or some other resou

4条回答
  •  心在旅途
    2021-01-11 23:42

    Standard for a reply/forward is > prepending each line the number of times the mail is nested including who sent the initial e-mail is up to the client to sort out. So what you need to do in python is simply add > to the start of each line.

    imap Test  Wrote:
    >
    >twice
    >imap Test wrote:
    >> nested
    >>
    >> imap@gazler.com wrote:
    >>> test
    >>>
    >>> -- 
    >>> Message sent via AHEM.
    >>>   
    >>
    >
    

    Attachments just simply need to be attached to the message or as you put it 'go wild.'

    I am not familiar with python, but believe the code would be:

    string = string.replace("\n","\n>")
    

提交回复
热议问题