Search code examples
pythonoutlookoutlook-2010win32com

win32com when parsing Outlook 2010. Instance showed up instead of the name/subject of the folder/message


I had this problem in the afternoon. The code works perfectly fine in the morning. I am very confused why it happened.

import win32com.client  
outlook = win32com.client.dynamic.Dispatch("Outlook.Application").GetNamespace("MAPI")
folder = (outlook.Folders)[1]
print(folder)

the result is this:

<win32com.gen_py.Microsoft Outlook 14.0 Object Library.MAPIFolder instance at 0x37167984>
Process finished with exit code 0

in the morning, I could get the name of the folder by simply

print(folder)

However, I don't know what settings I changed, I now need to put ".Name" after folder in order to get the folder's name

print(folder.Name)

Why did this happen?


Solution

  • I do not know why it did happen, but correct syntax is folder.Name