Reputation: 101
I have been using the below code to access a public folder in Outlook:
import win32com.client
import datetime
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
inbox = outlook.GetDefaultFolder(18).Folders.Item("xxxxx")
messages = inbox.Items
date = datetime.date.today()
subject = "xxxxxxx"
for message in messages:
if subject in message.subject and date in message.senton.date():
print(message.senton.time())
However, our Outlook has been moved from an Exchange server to the cloud and public folders have been changed to shared folders (I think?). The above code no longer works and I get the below error:
pywintypes.com_error: (-2147352567, 'Exception occurred.', (4096, 'Microsoft Outlook', 'The attempted operation failed. An object could not be found.', None, 0, -2147221233), None)
Is there any way to search emails from a shared mailbox?
Thanks
Upvotes: 1
Views: 2191
Reputation: 26
Try this:
inbox = outlook.Folders("Name of Shared Folder").Folders.Item("xxxxx")
Upvotes: 1