打开 Outlook 电子邮件后,我需要打印正文。这是代码:
import win32com.client as client
outlook=client.Dispatch("Outlook.Application").GetNamespace("MAPI")
inbox=outlook.GetDefaultFolder(6)
messages = inbox.Items
print(inbox.Items.Count)
print(inbox.Parent.Name)
for i in range(5):
message = messages.GetNext()
print(""+message.Subject, str(message.ReceivedTime))
print(message.Body)
错误是这样的:
Traceback (most recent call last): File "c:/Users/source/repos/Tests/pru.py", line 12, in <module> print(message.Body) File "C:\Users\venvs\frameworkenv\lib\site-packages\win32com\client\__init__.py", line 583, in __getattr__ return self._ApplyTypes_(*args) File "C:\Users\venvs\frameworkenv\lib\site-packages\win32com\client\__init__.py", line 572, in _ApplyTypes_ self._oleobj_.InvokeTypes(dispid, 0, wFlags, retType, argTypes, *args), pywintypes.com_error: (-2147467260, 'Operation aborted', None, None)