使用EWS时,CcRecipients和DisplayCc不匹配

时间:2019-11-26 15:43:59

标签: vb.net exchangewebservices

我正在尝试使用EWS获取CC电子邮件地址的列表。我可以看到DisplayCc中有一个值,但是CcRecipients为空。 (请参阅链接图像以查看值。)我在做什么错了?

Dim eItem As EmailMessage = DirectCast(mItem, EmailMessage)
Dim eas As String = eItem.DisplayCc
Dim accRecipients As EmailAddressCollection = eItem.CcRecipients
For Each eccrecipient In accRecipients
    Dim ea As String = eccrecipient.ToString
Next

enter image description here

1 个答案:

答案 0 :(得分:0)

这是一个DUH!我要做的就是在尝试获取eItem.CcRecipients之前先加载电子邮件。现在我的代码可以正常工作了。

Dim eItem As EmailMessage = DirectCast(mItem, EmailMessage)
**eItem.load**
Dim eas As String = eItem.DisplayCc
Dim accRecipients As EmailAddressCollection = eItem.CcRecipients
For Each eccrecipient In accRecipients
    Dim ea As String = eccrecipient.ToString
Next