While fetching attendee data from Exchange using EWS, for some user (for some clients), we are receiving X500 address instead of valid email address.
So, Please answer below queries:
1. How to replicate the same on our environment (ie how to get X500 address for adding this for exchange Email)?
2. How to handle this X500 Address ( ie steps to convert this X500 address into valid email address)?
3. How to Validate X500 Address ( ie to find whether this is valid X500 address or not)?
4. Is there any other property in response which can return valid Email Address?
Below is detail explanation:
1 How we are getting the X500 address?
We are not trying to fetch X500 address.
We are fetching meeting information from Exchange using EWS and retrieving Attendee information from response. But in response, for some users, we found X500 address instead of attendee email address, which is not valid email address.
2 What EWS request is used to get the X500 address?
We are using BeginSyncFolderItems and EndSyncFolderItems.
3 Steps to call EWS programatically:
a) Create object of ExchangeService.
List down other propeties ie PropertySet | FolderId | ObjectState
Url : https://outlook.office365.com/EWS/Exchange.asmx
Credentials will be OAuthCredentials (ie new OAuthCredentials(token))
ExchangeService ExchangeServiceProcessor = new ExchangeService();
Then we call BeginSyncFolderItems.
b) Then in response, we fetch the services ie
var ExchangeServiceProcessor = ((dynamic)ObjAsyncResult.AsyncState).Service;
Then we call EndSyncFolderItems ie
ChangeCollection<ItemChange> ChangedAppointment = ExchangeServiceProcessor.EndSyncFolderItems(ObjAsyncResult);
Then we fetch the Itemid.
c) Then we call serviceResponse collection based on itemId ie
d) Then we fetch the appointment with response ie
Appointment ConvertedAppointment = (Appointment)BindResponse.Item;
This will further provides us attendee ie appointment.OptionalAttendees | appointment.RequiredAttendees.
Here we have Microsoft.Exchange.WebServices.Data.EmailAddress object which have Name & Address values.