0
私は電子メールの内容を読もうとしています。電子メールはBODY部分に画像が含まれている場合、私はここで地元 でそれを抽出して保存する必要が解決策を見つけたpython:電子メールの本文から画像を抽出してダウンロードします
def get_body(id):
res, mail_data = connection.fetch(id, '(RFC822)')
raw_email=mail_data[0][1]
email_message_instance = email.message_from_string(raw_email)
whole_body = ''
for part in email_message_instance.walk():
if part.get_content_type() == "text/plain": # ignore attachments/html
body = part.get_payload(decode=True)
whole_body += body + ' '
else:
continue
return whole_body
[Pythonのファイルオブジェクトへの取得、メールの添付ファイル](http://stackoverflow.com/questions/4067937/getting-mail-attachment-to-python-file-object) –
の可能性の重複は、それがする@AriGoldそれは身体の中に直接になるアタッチメントではありません。全体像は体にある – user3125261
あなたはすでに体を取得する方法を知っていますか? –