0
votes

Since we moved to the Office Semi-Annual Enterprise Channel, version 1908, build 11929.20838, I cannot access the body or even the sender of the e-mails anymore via MAPI.

Python version: tried   3.6.8 32-bit,  3.6.8 64-bit  and  3.8.2 32-bit.
Pywin32 version: tried  228  and  227

I am wondering why this is happening, since it still works fine on previous versions of Office (not Enterprise).

=== Code example ===

import win32com.client

def checkOutlookInbox():
    account = '[email protected]'
    outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
    inbox = outlook.Folders(account).Folders("Inbox")
    messages = inbox.Items

    for message in messages:
        msg = message.body
        sender = message.Sender
        print(sender)
        print(msg)

=== Output (error) ===

File "C:\Python36-32Bit\lib\site-packages\win32com\client\dynamic.py", line 516, in getattr ret = self.oleobj.Invoke(retEntry.dispid,0,invoke_type,1) pywintypes.com_error: (-2147467259, 'Unspecified error', None, None)

===

Any ideas why this is happening on this specific Office version?

1

1 Answers

0
votes

Firstly, you are not using MAPI - this is Outlook Object Model. Secondly, are you ure you only have mail item objects in the Inbox, and not report items (NDRs) or meeting requests/updates?