Я пробовал это
import win32com.client
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
sample= outlook.GetDefaultFolder(6).Folders['Sample']
for message in sample.Items:
print(message.Subject)
Но получаю следующую ошибку
Traceback (most recent call last):
File "movemail.py", line 4, in <module>
sample= outlook.GetDefaultFolder(6).Folders['Sample']
File "C:\Program Files\Python38\lib\site-packages\win32com\client\dynamic.py", line 256, in __getitem__
return self._get_good_object_(self._oleobj_.Invoke(dispid, LCID, invkind, 1, index))
pywintypes.com_error: (-2147352567, 'Exception occurred.', (4096, 'Microsoft Outlook', 'The attempted operation failed. An object could not be found.', None, 0, -2147221233), None)
Я использую Outlook 2016 и pywin32 версии 227