用户定义字段更新后删除已发送的项目VSTO outlook c#

时间:2018-06-02 17:44:03

标签: c# .net outlook vsto

我有一个用户属性,它在邮件项列中添加了Yes / no标志。我在用户发送电子邮件时添加了该属性,并且它来自已发送的项目。我能够添加属性并正确显示但在发送项目文件夹更新后它就消失了。我找不到任何理由。以下是代码。

MailItemInfo objInfo = new MailItemInfo(Globals.ThisAddIn.Application.GetNamespace("MAPI"));
                Microsoft.Office.Interop.Outlook.MailItem msg = (Microsoft.Office.Interop.Outlook.MailItem)item;                    
                objInfo.SetStoreIDAndEntryID(msg);
                MailUtilities util = new MailUtilities();

                 var userproperty = msg.UserProperties.Add("SaveSend", Microsoft.Office.Interop.Outlook.OlUserPropertyType.olYesNo, true, 1);
                userproperty.Value = true;
                msg.Save(); // for saving mail item

寻求帮助。

1 个答案:

答案 0 :(得分:0)

看起来您需要在“已发送邮件”文件夹中定义用户属性。尝试检查Folder.UserDefinedProperties属性,该属性返回一个UserDefinedProperties对象,该对象表示用户定义的Folder对象的自定义属性。

UserDefinedProperties集合仅包含用户定义属性的定义,这些属性适用于该文件夹包含的所有Outlook项目。若要检索或更改该文件夹中Outlook项目的用户定义属性值,请使用Outlook项目的UserProperties属性(例如MailItem对象)来检索UserProperties集合中的UserProperty集合。那个项目。然后,您可以使用 I = 0; j = 0; For (i = 0; 0 < finalTitle.length; I++){ For (j = 0; 0 < finalDescription.length, I++) { finalTitle + ‘/n’ + finalDescription } } 对象获取相应的用户定义属性,以检索或更改Outlook项目的用户定义属性的值。