0

I have an Outlook add-in which assigns a UserProperty to a MailItem before it is sent:

Outlook.UserProperty prop = mail.UserProperties.Add("XXXX", Outlook.OlUserPropertyType.olText);
prop.Value = "YYYY";

It is known (see Stop Outlook from converting HTML to RTF for example) that doing this causes the email to be sent using TNEF (ie RTF format, the dreaded winmail.dat).

My question is, is it safe to simply un-set the TNEF property? The following code will do that:

mail.PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/id/{00062008-0000-0000-C000-000000000046}/8582000B", false);

The issue here is that I have to do this on ItemSend - I can't do it straight after I set the property, because it's always false anyway at that point. It only turns true when I hit Send.

I don't mind the fact that un-setting the TNEF property will mean that the property does not get sent with the email. I am more concerned that there may be other situations where TNEF is actually required and that this code would break them.

Or alternatively, is there a better way altogether of "tagging" an email with a custom ID number before it is sent?

Community
  • 1
  • 1
HughHughTeotl
  • 5,439
  • 3
  • 34
  • 49

2 Answers2

2

There is no anything strange in preventing winmail.dat from sending. You can continue un-setting the TNEF property in the ItemSend event.

Be aware, Outlook tracks related messages by using Conversations. You can use the Conversation* (*ID + *Index) related properties to identify emails in your Inbox.

See Does Outlook embed a MessageID or equivalent in its email elements? for more information.

Community
  • 1
  • 1
Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
2

Do not use UserProperties collection to tag a message - it updates both the blob with the user properties' definition and the named property where the user prop value is stored. If you use MailItem.PropertyAccessor.SetProperty to set the latter without setting the former, Outlook will not force the TNEF format.

It is safe to set the UseTnef property to false unless you are sending in the RTF format - check if that property is set to true before resetting it to false.

Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78