Question

I am trying to access another persons calendar using EWS. I can access my own calendar fine:

    foreach (Appointment appointment in service.FindItems(
        WellKnownFolderName.Calendar, new ItemView(int.MaxValue)))
    {
        Console.WriteLine(appointment.Subject);
    }
}

However when I try and impersonate (even with delegate access) I get an unhandled exception error with the below code (sorry its the full code but thought as its short it may help!) The problem child appears to be in the foreach loop

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Exchange.WebServices.Data;
using Test.ExchangeServices;
 using System.Net;

namespace Test
{
class Program
{
    static void Main(string[] args)
    {
 // Connect to Exchange Web Services
    ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP1);

    service.Credentials = new WebCredentials("User", "Pass", "Domain");
    service.Url = new Uri("https://EWS/EWS/Exchange.asmx");

    //Impersonate the user who is creating the appiontment request (doesn't work so commented out)
// service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, userEmail);

/Delegate access 

    foreach (Appointment appointment in service.FindItems(
new FolderId(WellKnownFolderName.Calendar, new Mailbox("otheremployee@company.com")), 
new ItemView(10)))
    {
        Console.WriteLine(appointment.Subject);
    }
}



    }
}

I have attached a screenshot of the error if it helps:

http://i44.tinypic.com/nh1jdi.png

Was it helpful?

Solution

You require reviewer access to the calendar and then it will work. :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top