Prabhu
Prabhu

Reputation: 717

outlook 2007 addin : How to remove particular userproperty of mailItem

I am developing utility application in Outlook 2007

I am able to add User property for Particular mailItem

<i>
  myMailItem.UserProperties.Add("ParentMailRecipients",     Outlook.OlUserPropertyType.olText,true, Outlook.OlUserPropertyType.olText);
            myMailItem.UserProperties["ParentMailRecipients"].Value = SavedMailItem.To + ";" + SavedMailItem.CC;
            myMailItem.Save();
 </i>

After a period of time I need to delete the particular User property.

User Property has the method for removing the user property(Remove(int))

I dont know How to find the index of particular User property and Delete it. Please help me to find solution?

Upvotes: 2

Views: 2457

Answers (1)

Kapil
Kapil

Reputation: 9969

You can search retrieve the UserProperty from the UserProperties collection using property name and once you have the UserProperty Object, call Delete method on that.

UserProperty up = myMailItem.UserProperties["ParentMailRecipients"];
if(up != null)
    up.Delete();

Upvotes: 9

Related Questions