C # to capture Outlook Email body

EDIT No. 2 ---- It compiles fine, but I get a debugging error: The URL property in the ExchangeService should be set on this line On this line of code, 'FindItemsResults findResults = service.FindItems (WellKnownFolderName.Inbox, new ItemView (128)); '' End EDIT # 2 ----

EDIT --- Uh - I didn’t understand that I needed 10 points to post an image ... let me give you some errors.

1) Type or namespace 'FindItemsResults' could not be found
2) Type or namespace name 'Item' could not be found
3) The name 'service' does not exist in the current context
4) Type or namespace 'ItemView' could not be found

EDIT ----

I saw a message here - How to get email, receipt, sender and CC information using EWS? and looked at this code sample

public class MailItem
{
    public string From;
    public string[] Recipients;
    public string Subject;
    public string Body;
}

public MailItem[] GetUnreadMailFromInbox()
{
    FindItemsResults<Item> findResults = service.FindItems(WellKnownFolderName.Inbox, new ItemView(128));
    ServiceResponseCollection<GetItemResponse> items =
        service.BindToItems(findResults.Select(item => item.Id), new PropertySet(BasePropertySet.FirstClassProperties, EmailMessageSchema.From, EmailMessageSchema.ToRecipients));
    return items.Select(item =>
    {
        return new MailItem()
        {
            From = ((Microsoft.Exchange.WebServices.Data.EmailAddress)item.Item[EmailMessageSchema.From]).Address,
            Recipients = ((Microsoft.Exchange.WebServices.Data.EmailAddressCollection)item.Item[EmailMessageSchema.ToRecipients]).Select(recipient => recipient.Address).ToArray(),
            Subject = item.Item.Subject,
            Body = item.Item.Body.ToString(),
        };
    }).ToArray();
}

But I get multiple compilation errors. How is a very clear way to read the body of a letter using C #?

+4
1

, MS Exchange Microsoft.Exchange.WebServices.dll

using using Microsoft.Exchange.WebServices.Data;

(3) , .

ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010);

. API- Microsoft Exchange Web 2.0

MSDN docs +

+1

All Articles