Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/270.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Outlook MailItem用户共享属性_C#_Outlook_Vsto_Outlook Addin - Fatal编程技术网

C# Outlook MailItem用户共享属性

C# Outlook MailItem用户共享属性,c#,outlook,vsto,outlook-addin,C#,Outlook,Vsto,Outlook Addin,如何设置Outlook.MailItem的属性,该属性随后不会与收件人共享 示例代码: Outlook.UserProperties mailUserProperties = null; Outlook.UserProperty mailUserProperty = null; try { mailUserProperties = mail.UserProperties; mailUserProperty = mailUserProperties.Add("TestUserPro

如何设置Outlook.MailItem的属性,该属性随后不会与收件人共享

示例代码:

Outlook.UserProperties mailUserProperties = null;
Outlook.UserProperty mailUserProperty = null;
try
{
    mailUserProperties = mail.UserProperties;
    mailUserProperty = mailUserProperties.Add("TestUserProperty", 
       Outlook.OlUserPropertyType.olText);
    mailUserProperty.Value = "test123";
    mail.Save();
}
catch
{
}
finally
{
    if (mailUserProperty != null) Marshal.ReleaseComObject(mailUserProperty);
    if (mailUserProperties != null) Marshal.ReleaseComObject(mailUserProperties);
}
然后,如果电子邮件是通过Exchange发送的,则在收件人的系统上获取其
TestUserProperty
仍会返回
test123
,因此该属性将与收件人共享。SMTP不会发生这种情况


那么,有没有一种方法可以(a)创建一个不与收件人共享的用户属性,或者(b)将数据附加到一个不共享的
Outlook.MailItem
上?

为什么不在发送邮件时删除用户属性(Application.ItemSend)?

谢谢。无法将其删除,因为在“已发送邮件”文件夹中查看邮件时,需要将该属性作为“标志”。从表面上看,我们可以在发送时取消设置标志,然后在它到达已发送邮件时重新设置标志,但我不确定这是否可以可靠地完成?您可以使用已发送邮件文件夹上的Items.ItemAdd事件使用user属性重新映射邮件。