使用 EWS NotificationEvent (Microsoft.Exchange.WebServices.Data.ItemEvent) 检索电子邮件失败

问题描述 投票:0回答:1

我正在运行一个从NotificationEvent的itemID检索电子邮件的源,如下面的源所示。 ーーーー Microsoft.Exchange.WebServices.Data.ItemEvent itemEV = (Microsoft.Exchange.WebServices.Data.ItemEvent)e; Item item = Item.Bind(ewsClient, itemEV.ItemId); Microsoft.Exchange.WebServices.Data.EmailMessage emailData = (Microsoft.Exchange.WebServices.Data.EmailMessage)item; ーーーー

最近,Item.Bind 出现错误,出现以下信息。 ーーーー EWS Id 采用 EwsLegacyId 格式,您的请求指定的 Exchange 版本不支持该格式。请使用 ConvertId 方法从 EwsLegacyId 转换为 EwsId 格式。 ーーーー

看起来NotificationEvent的itemID需要转换,但我想知道是否有解决方法。 (看来EWS的ID格式需要改一下,但是我觉得把EWS的大写k的值改一下会有点奇怪,所以就问了这个问题。)

c# .net exchangewebservices
1个回答
0
投票

他们似乎破坏了 EWS 中的某些东西 - 我希望这只是暂时的,但如果您也需要解决方法,这暂时有效:

    public string ConvertLegacyEwsIdToEwsId(string smtpAddress, string entryId)
    {
        AlternateId inputId = new AlternateId
        {
            Format = IdFormat.EwsLegacyId,
            Mailbox = smtpAddress,
            UniqueId = entryId
        };

        AlternateId alternateId = (AlternateId)_service.ConvertId(inputId, IdFormat.EwsId);
        return alternateId.UniqueId;
    }
© www.soinside.com 2019 - 2024. All rights reserved.