outlook 2007 addin:如何删除mailItem的特定userproperty

Pra*_*bhu 2 c# outlook-2007

我正在Outlook 2007中开发实用程序

我可以为特定的mailItem添加User属性

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

一段时间后,我需要删除特定的用户属性.

User Property具有删除用户属性的方法(Remove(int))

我不知道如何找到特定用户属性的索引并删除它.请帮我找到解决方案?

Kap*_*pil 8

您可以使用属性名称从UserProperties集合中搜索UserProperty,并在拥有UserProperty对象后,在其上调用Delete方法.

UserProperty up = myMailItem.UserProperties["ParentMailRecipients"];
if(up != null)
    up.Delete();
Run Code Online (Sandbox Code Playgroud)