none
EWS - Link to all Calendars RRS feed

  • Question

  • 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 Wednesday, November 20, 2013 9:56 AM
    Wednesday, November 20, 2013 9:54 AM

All replies

  • 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.


    There's no place like 127.0.0.1

    Wednesday, November 20, 2013 10:26 AM
  • 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 Wednesday, November 20, 2013 10:36 AM
    Wednesday, November 20, 2013 10:35 AM
  • I've managed to set the app Application Impersonation permissions and the page now works. I've also managed to impersonate a user and display their current appointment.

            service.ImpersonatedUserId = New ImpersonatedUserId(ConnectingIdType.SmtpAddress, "james.smith@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
    
                If Now() >= app.Start And Now() <= app.End Then
                    TextBox1.Text += "Subject: " + app.Subject + vbCrLf
                    TextBox2.Text += "Start: " + app.Start + vbCrLf
                End If
    
            Next

    But how could I code the two points below you mentioned.

    - first need to find all mailboxes

    - Set impersonation on the ExchangeService Object

    Thanks v much



    • Edited by ddunn10 Wednesday, November 20, 2013 1:49 PM
    Wednesday, November 20, 2013 1:14 PM