0

For an email that I send automatically via python with the win32com library I need to add something to the email header property. Code is like this:

olMailItem = 0x0
obj = win32com.client.Dispatch("Outlook.Application")
newMail = obj.CreateItem(olMailItem)
newMail.Subject = "test mail"
newMail.BodyFormat = 2
newMail.HTMLBody = html_out
newMail.To = email_recipient
newMail.PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/string/%7B00020386-0000-0000-C000-000000000046%7D/_test_", 'xyz')

Now I'm having issues with the underscores in the schemaName so it won't accept "_test_". Somehow I can escape the first underscore in the python way with a backslash like that ...%7D/\_test_", 'xyz') which would then work if I remove the second underscore. However for the second underscore I have not found a solution to escape it so that it is accepted.

Basically Outlook should be able to handle this because I read _test_ out of an exiting email header.

Any clue here? I can not find any restrictions for the string namespace

cederic
  • 11
  • 2

1 Answers1

0

Outlook applies its business logic and also introduces some limitations when dealing with OOM. As a workaround you may try to use a low-level API on which Outlook is based on - Extended MAPI or just any third-party wrappers around that API such as Redemption, for instance. You can try using MFCMAPI for playing with property names manually.

Also you may try to append the property name with any meaningful symbol.

Internet headers naming convention is described on the Custom HTTP headers : naming conventions thread.

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45