Receiving Email Attachments in App Engine Python errors on Unicode Text File

后端 未结 2 1993
情书的邮戳
情书的邮戳 2021-01-15 03:51

I have some code to parse an email and find the attachments then store them into the Datastore as db.BlobProperties (might change that to Blobstore later). The problem is t

2条回答
  •  迷失自我
    2021-01-15 04:33

    Check if this code helps:

    ===========================

       my_file = []
        my_list = []
        if hasattr(mail_message, 'attachments'):
            file_name = ""
            for filename, filecontents in mail_message.attachments:
                file_name = filename
                file_blob = filecontents.payload
                file_blob = file_blob.decode(filecontents.encoding)
                my_file.append(file_name)
                my_list.append(str(store_file(self, file_name, file_blob)))
    

提交回复
热议问题