Sep-21-2017, 11:28 AM
i am trying to read outlook mail and getting below error while running the code
Error:[quote]Traceback (most recent call last):
File "read_mail.py", line 10, in <module>
body_content = message.body
File "C:\Program Files\Python35\lib\site-packages\win32com\client\__init__.py", line 473, in __getattr__
raise AttributeError("'%s' object has no attribute '%s'" % (repr(self), attr))
AttributeError: '<win32com.gen_py.Microsoft Outlook 16.0 Object Library._MailItem instance at 0x1940794795848>' object has no attribute 'body'[/quote]
and below is my code which i am running.import win32com.client outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI") inbox = outlook.GetDefaultFolder(6) # "6" refers to the index of a folder - in this case, # the inbox. You can change that number to reference # any other folder messages = inbox.Items message = messages.GetLast() body_content = message.body print (body_content)and i am using
Quote:python 3.5.2