如何在EWS中从已发送的邮件中获取收件人邮箱

本文关键字:获取 收件人 EWS | 更新日期: 2023-09-27 18:01:55

我在EWS中循环发送的项目,并尝试显示每个发送的电子邮件,收件人,主题,正文等的详细信息。但是,我发现发送的邮件消息中的接收者是空的。如何取得收件人电邮地址?我的代码:

ItemId id = (ItemId)Request["id"]; // this id is the item id of WellKnownFolderName.**SentItems**
        EmailMessage current = EmailMessage.Bind(service, id);
        La_Subject.Text = current.Subject;
        La_From.Text = current.Sender.ToString();
        La_Sent.Text = current.DateTimeReceived.ToString();
        La_To.Text = current.ReceivedBy.ToString(); // This line error occurs

任何想法?

如何在EWS中从已发送的邮件中获取收件人邮箱

要获取邮件的收件人,请使用邮件消息的DisplayTo和DisplayCC属性。

或者自己遍历to接收者集合并自己构建字符串:

var toRecipients = string.Join(", ",
    mail.ToRecipients.Select(
        address => string.Format("'"{0}'" <{1}", address.Name, address.Address)));

ReceivedBy属性用于委托场景。见http://msdn.microsoft.com/en-us/library/microsoft.exchange.webservices.data.emailmessage.receivedby (v = exchg.80) . aspx。