Hi,
I'm hoping you guys can help me, I'm trying to alter one of the code examples from the Exchange Code Examples.
https://code.msdn.microsoft.com/Exchange-2013-101-Code-3c38582c
The one I'm trying to alter is the "Creating Weekly Recurring Appointment" but I'm having an issue. I'm trying to change it so that it uses the current logged on user credentials instead of having to type them in via the console window. The problem I'm having is that when I come to query the server I'm not getting that users Calender, and I suspect that users folders in general.
This is how I'm getting the current users credentials:
Uri uri = new Uri("http://tempuri.org/"); ICredentials credentials = CredentialCache.DefaultCredentials; NetworkCredential credential = credentials.GetCredential(uri, "Basic");
This is the change to the auto discover code:
if (userData.AutodiscoverUrl == null) { Console.Write(string.Format("Using Autodiscover to find EWS URL for {0}. Please wait... ", userData.EmailAddress)); service.AutodiscoverUrl(System.DirectoryServices.AccountManagement.UserPrincipal.Current.EmailAddress, RedirectionUrlValidationCallback); userData.AutodiscoverUrl = service.Url; Console.WriteLine("Autodiscover Complete"); }
However, when I run this code:
var a = service.FindFolders(WellKnownFolderName.Inbox, new FolderView(10));
it is returning the folders from a different users inbox.
Why is this?
Other symptoms: When I run the default "CreateWeeklyRecurringAppointment" method from the example with my changes in place the appointment is created in the other users calender and not the current logged in user.
If you can provide any insight it would be hugely appreciated.
Thanks,
Nik