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";
    }

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

相关文章

vue阻止冒泡事件 阻止点击事件的执行 &lt;div @click=&a...
尝试过使用网友说的API接口获取 找到的都是失效了 暂时就使用...
后台我拿的数据是这样的格式: [ {id:1 , parentId: 0, name:...
JAVA下载文件防重复点击,防止多次下载请求,Cookie方式快速简...
Mip是什么意思以及作用有哪些