Home > OS >  python3 use google app engine to receive email, than how to get date and size properly
python3 use google app engine to receive email, than how to get date and size properly

Time:03-21

I used GAE-mail to receive email, in the email handle, I am able to received body, sender, subject etc from mail_message.

mail_message = mail.InboundEmailMessage(data)
# supported attributes is=>{
         'amp_html',
         'attachments',
         'bcc',
         'body',
         'cc',
         'headers',
         'html',
         'reply_to',
         'sender',
         'subject',
         'to'
        }

however, I want some additional attributes, email_size and sentdate, what is the best practice to get these two attributes?

thanks in advance

CodePudding user response:

  1. Mail API from Python2 has the field below; it should work for Python3

date returns the message date.

  1. This sample code from Google shows length of the message. If you want the size in bytes, you should try getsizeof method instead of len. See this example
  • Related