Get body text of an email using python imap and email package

后端 未结 3 1177
慢半拍i
慢半拍i 2020-12-03 19:42

I want to retrieve body (only text) of emails using python imap and email package.

As per this SO thread, I\'m using the following code:

mail = email         


        
3条回答
  •  一整个雨季
    2020-12-03 20:02

    The main problem in my case is that replied or forwarded message shown as message instance in the bodytext.

    Solved my problem using the following code:

    bodytext=mail.get_payload()[0].get_payload();
    if type(bodytext) is list:
        bodytext=','.join(str(v) for v in bodytext)
    

提交回复
热议问题