exchange-server – Exchange Web Services(EWS)API“To”别名的标头

前端之家收集整理的这篇文章主要介绍了exchange-server – Exchange Web Services(EWS)API“To”别名的标头前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个收件箱设置作为交换,hello @ mycompany.com

此外,还有一个别名,news @ mycompany.com,因此所有发送到新闻地址的电子邮件都会在hello收件箱中结束.

理想情况下,我希望能够使用EWS告知发送电子邮件的别名.

当我向news@mycompany.com发送电子邮件,并使用Microsoft Outlook检查邮件的Internet标头时,To:标头读取To:Hello< news@mycompany.com\u0026gt;这正是我想要看到的. 但是,使用EWS时,当我查看邮件ToRecipients属性时,报告的电子邮件地址始终是主SMTP地址的电子邮件地址.此外,Webservices.Data.Item的InternetMessageHeaders属性不包含To:属性.我似乎也无法使用EWSEditor查看正确的地址来检查消息的所有属性.

this forum post的答案似乎表明,

…The Information about the actual email address a message is sent to is stored in the recipients collection which you can’t access (outside of exportmessage) in EWS…

我将如何以编程方式执行此操作,以便找到正确的To:地址?

解决方法

这对我有用:
private static string GetToAddress()
    {
        ExchangeService exService = new ExchangeService();
        exService.Credentials = new NetworkCredential("username","password","domain");
        exService.Url = new Uri("https://youraddress/EWS/Exchange.asmx");

        ExtendedPropertyDefinition PR_TRANSPORT_MESSAGE_HEADERS = new ExtendedPropertyDefinition(0x007D,MapiPropertyType.String);
        PropertySet psPropSet = new PropertySet(BasePropertySet.FirstClassProperties)
                                    {PR_TRANSPORT_MESSAGE_HEADERS,ItemSchema.MimeContent};

        FindItemsResults<Item> fiResults = exService.FindItems(WellKnownFolderName.InBox,new ItemView(1));
        foreach (Item itItem in fiResults.Items)
        {
            itItem.Load(psPropSet);
            Object valHeaders;
            if (itItem.TryGetProperty(PR_TRANSPORT_MESSAGE_HEADERS,out valHeaders))
            {
                Regex regex = new Regex(@"To:.*<(.+)>");
                Match match = regex.Match(valHeaders.ToString());
                if (match.Groups.Count == 2)
                    return match.Groups[1].Value;
            }
            return ToAddress;
        }
        return "Cannot find ToAddress";
    }@H_301_21@ 
 

代码来自:
http://social.technet.microsoft.com/Forums/en-au/exchangesvrdevelopment/thread/1e5bbde0-218e-466e-afcc-cb60bc2ba692

原文链接:https://www.f2er.com/html/225740.html

猜你在找的HTML相关文章