Link to home
Start Free TrialLog in
Avatar of Lynchie435
Lynchie435

asked on

Exchange Web Services (EWS) VB.NET

Morning,

I am creating a program that integrates with an Exchange Mailbox for Processing.

I wish to remove the part of the process that requires Outlook to be open a server and processing rules, so I have turned to using EWS.

The problem I have am having is return the 'FROM' field.

My code below I am able to connect to my Exchange Server and return the Category, To Field etc. perfectly fine, yet unable to return the From.

A lot of the documentation out there is written in C# of which i have NO experience.

Anyone pointing me in the right direction would be grand.

My Code:

        Dim exch As ExchangeService = New ExchangeService(ExchangeVersion.Exchange2007_SP1)
        Dim Uri As Uri

        Uri = New System.Uri("https://server/EWS/Exchange.asmx")
        exch.Url = Uri
        exch.UseDefaultCredentials = False
        exch.Credentials = New System.Net.NetworkCredential("ACCOUNT", "PASSWORD", "DOMAIN")

        exch.ImpersonatedUserId = New ImpersonatedUserId(ConnectingIdType.PrincipalName, "itprocessing@hq.freshinsurance.co.uk")

        ServicePointManager.ServerCertificateValidationCallback = AddressOf ValidateRemoteCertificate

        Dim iv As ItemView = New ItemView(10) ' return first 10 pages
        iv.Traversal = ItemTraversal.Shallow

        Dim InboxItems As FindItemsResults(Of Item) = Nothing

        InboxItems = exch.FindItems(WellKnownFolderName.Inbox, iv)

        For Each i As Item In InboxItems

            Console.WriteLine(i.Subject)
            Console.WriteLine(i.Categories)
            Console.WriteLine(i.DisplayTo)
            Console.WriteLine(i.HasAttachments)

            Dim strCat As String = i.Categories.ToString
        Next

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Snarf0001
Snarf0001
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Lynchie435
Lynchie435

ASKER

Hi Snarf0001,

That doesn't appear to  the case as its Blank.

However you put me on the right track and it was

Console.WriteLine(DirectCast(i, EmailMessage).Sender.Name)

Open in new window


That i was looking for :)

Cheers,

James