Ankush Gupta
Ankush Gupta

Reputation: 213

Exchange Web Service Managed API: How to read From Email Address?

I am using Exchange Web Service Managed API 1.1 version for some of my development task, I want to perform some operations on the incoming email message.

  1. Acknowledge the Sender
  2. Save the email message on disk as an html file (the same method provided as SaveAs option)

For the 1st problem in order to send the email to sender, I need to fetch the sender's email address. So, I tried the following, but no luck :( doing to the below I can get the Email message in which From contains only the name not the email address.

    EmailMessage email = EmailMessage.Bind(exchangeService, item.Id);
    Console.WriteLine(email.From.Address);

Could anyone help me out here.

Thanks,

Ankush Gupta

Upvotes: 2

Views: 4569

Answers (1)

Henning Krause
Henning Krause

Reputation: 5422

To answer the question in the comments:

EWS does not provide you with a way to directly save a message as HTML. You can, however, get the body of the mail as HTML using this property set:

mail.Load(new PropertySet(ItemSchema.Body) {RequestedBodyType = BodyType.HTML});

If you want something more fancy (like the Outlook save as html functionality), you'll have to combine the body with the From, ToRecipients, CCRecipients, Subject and Received property.

Upvotes: 2

Related Questions