[英]Define mailbox to which to save an email - win32client python
[英]How to read the body of an outlook email using Python / Win32Client?
如何使用 python 閱讀 Outlook 電子郵件的正文? 下面的第一個代碼允許我訪問該文件夾,但它繼續只返回消息主題。 我只需要消息的正文。
import win32com.client
import datetime
import os
import email
import pandas as pd
import os
import glob
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
inbox = outlook.GetDefaultFolder(6).Folders.Item("Eres")
message = inbox.items
for message in inbox.Items:
if message.unread == True:
print(message)
下面的這段代碼根本不起作用,並產生以下錯誤..
com_error Traceback(最近一次通話最后一次)在 16 17 message = messages.GetLast() ---> 18 body_content = message.body
~\Anaconda3\lib\site-packages\win32com\client\dynamic.py in getattr (self, attr) 514 debug_attr_print("Getting property Id 0x%x from OLE object" % retEntry.dispid) 515 try: --> 516 ret = 自我。 oleobj .Invoke(retEntry.dispid,0,invoke_type,1) 517 除了 pythoncom.com_error 作為詳細信息:518 如果 details.hresult 在 ERRORS_BAD_CONTEXT 中:
com_error:(-2147467259,'未指定的錯誤',無,無)
import win32com.client
import datetime
import os
import email
import pandas as pd
import os
import glob
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
inbox = outlook.GetDefaultFolder(6).Folders.Item("Eres")
messages = inbox.Items
message = messages.GetLast()
body_content = message.body
“com_error: (-2147467259, 'Unspecified error', None, None)” 這是一個安全問題。 可能是由您的防病毒軟件引起的。 解決方案: Win32com Outlook 正文屬性錯誤
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.