'Add a hidden tag to outgoing mail

I create a mail by VBA when sending invoices and automated newsletters by Outlook (2019).

For reimporting the mails from the Sent folder into the database it would be convenient to read a hidden tag including the customer number which I would like to embed into the mail.



Solution 1:[1]

You can add a custom property either using MailItem.UserProperties.Add or by setting your custom property directly using MailItem.PropertyAccessor.SetProperty.

Keep in mind adding a user property can force Outlook to send in the RTF format (the infamous winmail.dat attachment), so the latter solution is preferable. You just need to make sure you get the DASL property name (to be used with MailItem.PropertyAccessor.SetProperty) right. You can use the former approach (MailItem.UserProperties.Add), take a look at the message in the Sent Items folder with OutlookSpy (I am its author - click IMessage button), then use the DASL property name replacing MailItem.UserProperties.Add with MailItem.PropertyAccessor.SetProperty

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1