通过 exchange webservices 移动到另一个文件夹后如何通过 id 或 guid 访问电子邮件

How to access a email by id or guid after move to another folder via exchange webservices

我有一个这样的 public 文件夹结构:

Test\Incoming
Test\Read

我将以下代码与 Microsoft.Exchange.WebServices Version 2.2 一起使用:

//Get Email
EmailMessage mailItem = EmailMessage.Bind(service, ItemID, new PropertySet(BasePropertySet.FirstClassProperties));

//Get UniqueId "FirstID"
mailItem.Id.UniqueId

//Move Email to Incoming\Read
mailItem.Move(destinationFolderID);

//After moving the UniqueId changed to "ChangedID"
mailItem.Id.UniqueId

有没有办法通过 id/guid 访问移动的电子邮件,因为 UniqueId 不是常量

这取决于移动发生的位置,例如,如果您移动到同一邮箱中的另一个文件夹(在 Public 文件夹的情况下,它可能取决于您有多个 public 文件夹邮箱的位置和这些文件夹在不同的邮箱上)然后移动方法将 return 项目的新 ID 所以

//Move Email to Incoming\Read
NewItem = mailItem.Move(destinationFolderID);

//After moving the UniqueId changed to "ChangedID"
NewItem.Id.UniqueId

如果您将它移动到另一个邮箱中的文件夹,则 MoveItem 操作不会 return newid,您将需要使用 SearchKey 或其他自定义方式在新文件夹中搜索该项目属性你设置