Bubuhubu
Bubuhubu

Reputation: 81

How to automatically add custom user properties to all new reply in Outlook VSTO

I am developing Outlook VSTO add-in where we assign custom user properties call "Ownership" to all new emails. The code I use is below.

string UserName = (string)application.ActiveExplorer().Session.CurrentUser.Name;

MailUserProperties = SelectedMail.UserProperties;
                MailUserProperty = MailUserProperties.Add("Ownership", Outlook.OlUserPropertyType.olText, true, 1);
                MailUserProperty.Value = UserName;
                SelectedMail.Save();

Is it possible that when someone replies to us, Outlook would automatically pick up "Ownership" properties value from original email and assign to all incoming replies?

Thank you in advance.

Upvotes: 1

Views: 855

Answers (1)

Eugene Astafiev
Eugene Astafiev

Reputation: 49435

You can handle the Reply event of the MailItem class where you may set all the required user properties.

There is no automatic way for doing so in Outlook. You must handle such scenarios in the code. The MailItem.GetConversation method allows obtaining a Conversation object that represents the conversation to which this item belongs.

GetConversation returns Null (Nothing in Visual Basic) if no conversation exists for the item. No conversation exists for an item in the following scenarios:

  • The item has not been saved. An item can be saved programmatically, by user action, or by auto-save.
  • For an item that can be sent (for example, a mail item, appointment item, or contact item), the item has not been sent.
  • Conversations have been disabled through the Windows registry.
  • The store does not support Conversation view (for example, Outlook is running in classic online mode against a version of Microsoft Exchange earlier than Microsoft Exchange Server 2010). Use the IsConversationEnabled property of the Store object to determine whether the store supports Conversation view.

Upvotes: 1

Related Questions