I am trying to add a UserProperty to an email using win32com. The UserPropertyType should be set to 'olText'.
For the record, the name of the UserProperty ('NewDomain') is already a member of the collection of Outlook UserProperties.
I have tried the following:
import win32com.client as w32c
outlook=w32c.Dispatch('Outlook.Application').GetNameSpace('MAPI')
inbox=outlook.GetDefaultFolder(6)
emails=inbox.Items
email=emails.GetLast()
email.UserProperties.Add("NewDomain",UserPropertyType='olText',True)
I got the following error: TypeError: Add() got an unexpected keyword argument 'OlUserPropertyType'
The code works well in VBA with the syntax: email.UserProperties.Add("NewDomain", olText, True)
Many thanks for you help!
UserPropertyType argument is an enum (int), not a string. olText is 1, so your code must be
email.UserProperties.Add("NewDomain", 1, True)