The only information I've found regarding my issue are from other StackOverflow questions that don't actually resolve my issue.
TypeError: '_Folders' object is not callable
Using Outlook via win32com, suddenly getting runtime error '_Folders' object is not callable`
Script has been working perfectly for the past 3 months, but has suddenly stopped working today (no changes were made between it working yesterday, and being broken today)
What confuses me the most is that I have tried the exact same script on another PC and it still works perfectly fine. (both transferring the problem .py file and also rewriting the code to a new script file)
Given the above, I assume the error is my PC specific, however I have no idea what it could be.
For reference, my Outlook has two accounts linked to it and I need to access the second account, so DefaultFolder() will not work
import win32com.client
mailbox = ['Address', 'Inbox']
outlook = win32com.client.Dispatch("Outlook.Application")
namespace = outlook.GetNamespace("MAPI")
# Returns the same error
inbox = namespace.Folders(mailbox[0]).Folders(mailbox[1])
inbox = namespace.Folders('Address').Folders('Inbox')
inbox = namespace.Folders('Address')
inbox = outlook.GetNamespace("MAPI").Folders('Address')
inbox = outlook.GetNamespace("MAPI").Folders('Address').Folders('Inbox')
# Error
>>> File c:\...\script.py, line 15, in <module>
>>> inbox = namespace.Folders('Address').Folders('Inbox')
>>> TyperError: '_Folders' object is not callable
Not sure if this confirms anything, however another test I did is as follows:
# Deliberately misspell .Folders()
inbox = namespace.folders('Address').Folders('Inbox')
# Error
>>> File c:\...\script.py, line 15, in <module>
>>> inbox = namespace.folders('Address').Folders('Inbox')
>>> AttributeError: '<win32com.gen_py.Microsoft Outlook 16.0 Object Library._NameSpace instance at 0x2380896888784>'
>>> object has no attribute 'folders'. Did you mean: 'Folders'?
# Deliberately misspell .Folders()
inbox = namespace.Folder('Address').Folders('Inbox')
# Error
>>> File c:\...\script.py, line 15, in <module>
>>> inbox = namespace.Folder('Address').Folders('Inbox')
>>> AttributeError: '<win32com.gen_py.Microsoft Outlook 16.0 Object Library._NameSpace instance at 0x2380896888784>'
>>> object has no attribute 'Folder'. Did you mean: 'Folders'?