Python - Extract the body from a mail in plain text

前端 未结 3 1776
挽巷
挽巷 2021-02-08 02:12

I want to extract only the body of a message and return it. I can filter on the fields and display the snippet but not the body.

def GetMimeMessage(service, user         


        
3条回答
  •  庸人自扰
    2021-02-08 02:38

    The base64url encoded string needs some alteration before passing into the decode function as below:

    msg_str = base64.urlsafe_b64decode(message['raw'].replace('-_', '+/').encode('ASCII'))
    

    See if this helps

提交回复
热议问题