Skip to content
This repository was archived by the owner on Jun 18, 2024. It is now read-only.
This repository was archived by the owner on Jun 18, 2024. It is now read-only.

[C#] GetUserPhoto missing in ExchangeService and results in 401 via WebRequest #610

@aaronegger

Description

@aaronegger

Hi,

i have some problem at loading the corresponding user photo of an email.
I have a list of emails from the "WellKnownFolderName.SentItems" casted to an object of type Microsoft.Exchange.WebServices.Data.EmailMessage.

From this object i can successfully obtain the Sender Email Address.
The MailboxType of the mail ist Microsoft.Exchange.WebServices.Data.MailboxType.Mailbox (if this is an important information)

I saw a solution at https://msdn.microsoft.com/en-us/library/office/jj190905%28v=exchg.150%29.aspx#bk_EWS
that i can use a GetUserPhoto function for Addresses of this MailboxType.

Firstly i tried to access the url: https://Exchange Server/ews/Exchange.asmx/s/GetUserPhoto?email=email address&size=size code
directly via a web browser.

(And now i am at the point where the issue begins)
Only the Internet Explorer worked, but i got an authorization prompt and i logged in with the same credentials as i am currently logged in at windows. Google Chrome just returned an 401 unauthorized.
(I am logged in with an AD account).

I also tried the code from the msdn website:
HttpWebRequest request =
WebRequest.Create("https://www.contoso.com/ews/exchange.asmx/s/GetUserPhoto?email=sadie@contoso.com&size=HR240x240")
as HttpWebRequest;
// Submit the request.
using (HttpWebResponse resp = request.GetResponse() as HttpWebResponse)
{
// Take the response and save it as an image.
Bitmap image = new Bitmap(resp.GetResponseStream());
image.Save("Sadie.jpg");
}

But this also failed with 401.

I suspect this as an issue from the service, because even the msdn code does not work out of the box.

Impersonating the current Windows Identity also didn't work.

Is there a way to access the function GetUserPhoto from the exchangeService instance?
The exchangeService instance is working flawless and therefore this would be the best option for me to use this function with it.

The assembly version i am using is 15.0.913.15.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions