Hi,
I am trying to forward an email using the ExchangeWebServicesClient, however I cant seem to find the email address of the current mailbox.
Hi,
I am trying to forward an email using the ExchangeWebServicesClient, however I cant seem to find the email address of the current mailbox.
Hi Aaron,
Thank you for your inquiry.
Email address of Exchange mailbox can be retrieved using the following code sample. Please give it a try at your end and share your feedback with us.
Code:
ServicePointManager.ServerCertificateValidationCallback += CheckCertificate;
{
ExchangeServiceBinding service = new ExchangeServiceBinding()
{
Credentials = new NetworkCredential("username", "password", "domain"),
Url = "server address"
};
ResolveNamesType request = new ResolveNamesType()
{
ReturnFullContactData = true,
UnresolvedEntry = ((NetworkCredential)service.Credentials).UserName,
SearchScope = ResolveNamesSearchScopeType.ActiveDirectoryContacts
};
ResolveNamesResponseType response = service.ResolveNames(request);
ResolveNamesResponseMessageType responseMessageType = response.ResponseMessages.Items[0] as ResolveNamesResponseMessageType;
string emailAddress = responseMessageType.ResolutionSet.Resolution[0].Mailbox.EmailAddress;
Console.WriteLine(emailAddress);
}