我在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
有什么想法吗?
答案 0 :(得分:0)
要获取邮件的收件人,请使用邮件的DisplayTo和DisplayCC属性。
或者自己遍历ToRecipients集合并自己构建字符串:
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。