【问题标题】:Get email message from Exchange using EWS Tracking Log Message ID or the InternalMessageID使用 EWS 跟踪日志消息 ID 或 InternalMessageID 从 Exchange 获取电子邮件消息
【发布时间】:2018-04-29 21:42:36
【问题描述】:

我正在开发一个应用程序来跟踪我们公司的交换电子邮件消息。 我们可以从跟踪日志中获取信息,但在日志中 - 通过设计 - 没有主题或正文消息。 因此,我们的下一步是在需要时使用 EWS 获取消息详细信息。 问题是我们在跟踪日志中找到了 ID:

MessageId,格式为“F533E7F015A2E24F8D8ABFE2587117C601EDF245@blstex02.subdomain.domain.com”

InternalMessageId,格式为“5840818”

如果在 EWS 中我们使用此 ID 按 ID 查找消息,我们总是会收到“ID 格式错误”。例外。 这是我们使用的代码:

public static EmailMessage GetEmailById(string uNameToImpersonate, string StringItemId)
        {
            return EmailMessage.Bind(GetService(uNameToImpersonate), new ItemId(StringItemId));
        }

我是 EWS 的新手,所以也许我错过了一些非常简单的东西...... 感谢您的帮助

【问题讨论】:

    标签: exchangewebservices exchange-server-2010


    【解决方案1】:

    您只能使用 EWSId 绑定到消息,请参阅https://msdn.microsoft.com/en-us/library/office/dn605828(v=exchg.150).aspx 以获得更详细的讨论。对于 InternetId,您将需要使用 findItem 操作搜索具有该特定 Id 的消息,例如

      ItemView ivew = new ItemView(1);
      service.TraceEnabled = true;
      ExtendedPropertyDefinition PidTagInternetMessageId = new ExtendedPropertyDefinition(4149, MapiPropertyType.String);
      SearchFilter sf = new SearchFilter.IsEqualTo(PidTagInternetMessageId, "F533E7F015A2E24F8D8ABFE2587117C601EDF245@blstex02.subdomain.domain.com");
      FindItemsResults<Item> iCol = service.FindItems(WellKnownFolderName.Inbox, sf, ivew);
    
      foreach (Item item in iCol.Items)
      {
        Console.WriteLine(item.Subject);
      }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-05-04
      • 2016-01-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-06
      • 1970-01-01
      • 2014-08-13
      相关资源
      最近更新 更多