I've got a small bit of code that connects to Exchange to get the appointments for a particular account. This account does not have a mailbox.
Dim service As New ExchangeService(ExchangeVersion.Exchange2010_SP2)
service.Credentials = New NetworkCredential("userID", "password")
service.AutodiscoverUrl("[email protected]")
Dim calView As New CalendarView(DateTime.Today, DateTime.Today.AddYears(2))
calView.Traversal = ItemTraversal.Shallow
calView.PropertySet = New PropertySet(BasePropertySet.FirstClassProperties, ItemSchema.Subject, AppointmentSchema.Location)
Dim mtgs As FindItemsResults(Of Item) = service.FindItems(WellKnownFolderName.Calendar, calView)
The code raises the following exception on the last line.
When making a request as an account that does not have a mailbox, you must specify the mailbox primary SMTP address for any distinguished folder Ids.
I've run the code with service.UseDefaultCredentials = True in place of the Credentials line and it executes but brings back my appointments, of course. Is there a fix for this? I think my alternative is to convince the Exchange admins to grant my account Impersonate privileges for the account of interest.