EWS - Link to all Calendars

Hi, I have been able to link an ASP.NET page into exchange to display meetings from the current day for a user.

What I would like to be able to do is retrieve the same info as before (all of the meetings for the current day), but instead retrieve them from all of the users.

Is this possible?

Below is my code to retrieve that information from one user.

Thanks very much

Imports Microsoft.Exchange.WebServices.Data

Partial Class Test
    Inherits System.Web.UI.Page


    Shared userEmail As String = "jsmith@mydomain.local"
    Shared userPassword As String = "theuserspassword"


    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load


        Dim service As New ExchangeService(ExchangeVersion.Exchange2010_SP1)

        service.Credentials = New WebCredentials(userEmail, userPassword)
        service.AutodiscoverUrl("administrator@mydomain.co.uk")

        Dim foundAppointments As FindItemsResults(Of Appointment) = service.FindAppointments(WellKnownFolderName.Calendar, New CalendarView(DateTime.Now, DateTime.Now.AddDays(1)))


        For Each app As Appointment In foundAppointments
            TextBox1.Text += "Subject: " + app.Subject + vbCrLf
            TextBox2.Text += "Start: " + app.Start + vbCrLf
        Next

    End Sub


End Class



  • Edited by ddunn10 2 hours 1 minutes ago
November 20th, 2013 4:58am

Hi ddunn,

yes, it is possible. Using impersonation, you can cycle through each mailbox and retrieve appointments. For that you ...
- first need to find all mailboxes
- foreach ...
- - Set impersonation on the ExchangeService Object
- - Retrieve Appointments

Cheers,
Fred

P.s.: Impersonation requires the ApplicationImpersonation permissions for the user.

Free Windows Admin Tool Kit Click here and download it now
November 20th, 2013 5:30am

Thanks Fred thats really helpful.

I have only started working with EWS last night, could you kindly help meout with how the code might look?

I have tried this line of code

service.ImpersonatedUserId = New ImpersonatedUserId(ConnectingIdType.SmtpAddress, "john.smith@raworths.co.uk")

But I'm getting this error.

The account does not have permission to impersonate the requested user.

Thanks for you help!


  • Edited by ddunn10 1 hour 21 minutes ago
November 20th, 2013 5:39am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics