Exchange Web Services - From Fields Not Populated??
Posted on 2014-02-10
I recently downloaded the Exchange Web Services SDK and have used it to create a small application who's aim is to extract data regarding email usage. One of the fields I am interested in is the sender and in particular I need to get the Sender's email address. Most of the other fields seem to contain what I want but anything that involves email addresses seems to be set to nothing yet the name field holds the sender's name. Here is the bare bones of what I am doing:
Dim Str As String = ""
Dim l As Integer = 0
Dim parentFolderName As WellKnownFolderName
Dim view As New ItemView(1000)
Dim returnValue As FindItemsResults(Of Item)
Dim x As Integer = 0
Dim n As Integer = 0
Dim service As ExchangeService = Nothing
service = New ExchangeService(ExchangeVersion.Exchange2010)
ServicePointManager.ServerCertificateValidationCallback = AddressOf CertificateValidationCallBack
service.Credentials = New WebCredentials(A.UserName, A.Password, A.Domain)
parentFolderName = WellKnownFolderName.Inbox
If returnValue.Items.Count > 0 Then
For j = 0 To returnValue.Items.Count - 1
Str = DirectCast(returnValue.Items(j), Microsoft.Exchange.WebServices.Data.EmailMessage).From.Address
If Str = "" Then
l += 1
When I interrogate the " DirectCast(returnValue.Items(j), Microsoft.Exchange.WebServices.Data.EmailMessage).From.Address" code the address is always nothing, if I look at:
That has the name of the sender which is not what I want, can anyone explain what I need to do to get the email address of the sender. I am also getting the same with the CC and BCC fields they are always empty even when there are actual CC and BCCs in the inbox email message I am interrogating.