Exchange EWS 获取密件抄送收件人

2023-12-21

我正在使用 EWS 创建一个StreamingSubscription在收件箱上。它正在监听NewMail事件。我可以提取发件人地址、主题、正文、收件人地址、抄送地址,但不能提取密件抄送地址。有什么办法可以看到这个列表吗?

CODE:

static void OnEvent(object sender, NotificationEventArgs args)
{
    String from = null;
    String subject = null;
    String body = null;
    String to = null;

    StreamingSubscription subscription = args.Subscription;

    // Loop Through All Item-Related Events
    foreach (NotificationEvent notification in args.Events)
    {
        ItemEvent item = (ItemEvent)notification;

        PropertySet propertySet = new PropertySet(ItemSchema.UniqueBody);
        propertySet.RequestedBodyType = BodyType.Text;
        propertySet.BasePropertySet = BasePropertySet.FirstClassProperties;

        // Parse Email
        EmailMessage message = EmailMessage.Bind(service, item.ItemId, propertySet);
        from = message.From.Address;
        subject = message.Subject;
        body = message.Body.Text;

        if (message.ToRecipients.Count > 0)
        {
            to = message.ToRecipients[0].Address;
            body += "\n TO FIELD";
        }
        else if (message.CcRecipients.Count > 0)
        {
            to = message.CcRecipients[0].Address;
            body += "\n CC FIELD";
        }
/************** Does not work! BccRecipients is always empty *****************/
        else if (message.BccRecipients.Count > 0)
        {
            to = message.BccRecipients[0].Address;
            body += "\n BCC FIELD";
        }

 /************* REST OF CODE ************************/
    }
}

这有点违背了密件抄送的意义。我不相信这是可以做到的。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Exchange EWS 获取密件抄送收件人 的相关文章

随机推荐