James L
James L

Reputation: 16874

How do I find the current user's own email address, using Exchange Web Services?

I am using UseDefaultCredentials = true to authenticate to EWS. It works fine for sending and receiving, but I now need to find out the email address of the current user, but I can't see any obvious way of doing this in the API.

Can anyone help?

Upvotes: 1

Views: 371

Answers (1)

Glen Scales
Glen Scales

Reputation: 22032

The easiest way is just to be use ConvertId with generic email address ([email protected] always work for me) eg if you use

        Folder Inbox = Folder.Bind(service, WellKnownFolderName.Inbox);
        AlternateId aiAlternateid = new AlternateId(IdFormat.EwsId, Inbox.Id.UniqueId, "[email protected]");
        AlternateIdBase aiResponse = service.ConvertId(aiAlternateid, IdFormat.EwsId);
        Console.WriteLine(((AlternateId)aiResponse).Mailbox);

EWS should return the correct SMTPAddress of the Mailbox in the Mailbox property returned by this operation.

Cheers Glen

Upvotes: 4

Related Questions