Hi I am using win32 Outlook via python to send email from a specific mailbox that is already connected from my Outlook app. Code is straightforward. I was able to run successfully last week.
import win32com.client as win32
outlook = win32.Dispatch('Outlook.Application')
mail = outlook.CreateItem(0)
for c in outlook.Session.Accounts:
mail.To = '[email protected]'
But today it failed with 'Accounts' object is not iterable'
I only installed xlrd last week.
Thanks you guys for the solution hint and explanation, this is exactly how the problem is solved.
for c in range(1, outlook.Session.Accounts.Count+1):
if (outlook.Session.Accounts.Item(c).DisplayName) == '[email protected]':
mailfrom = (outlook.Session.Accounts.Item(c))
#print(outlook.Session.Accounts.Item(c).DisplayName)