Accessing a Resource Calendar with no mailbox via EWS and C#

亡梦爱人 提交于 2019-12-07 07:25:25

问题


Our Exchange Admins (Exchange 2010 SP1) have setup a shared resource calendar. There is no mailbox assigned to this resource calendar. I want to be able to read the meetings using EWS and C#.

Snippet:

        ExchangeService esvc = new ExchangeService(ExchangeVersion.Exchange2010);
        esvc.Credentials = new WebCredentials(username, password, "ourplace.org");
        esvc.Url = new Uri("https://OWA.OURPLACE.ORG/EWS/Exchange.asmx");

        FolderId shareFolderId = new FolderId(WellKnownFolderName.Calendar, "Shared Calendar Name");
        CalendarFolder.Bind(esvc, shareFolderId);

the bind statement throws the error: "The SMTP address has no mailbox associated with it."

How can I read the items on a Share Resource Calendar that has no associated mailbox... or is it even possible?

Thanks !!


回答1:


Bind to that Calendar with a mail-Adress

Create first of all a FolderId:

FolderId parkplatzCalendarId = new FolderId(WellKnownFolderName.Calendar,"de.calendar.name@company.com");

Then bind to this one:

CalendarFolder calendar = CalendarFolder.Bind(_service, parkplatzCalendarId);

Now you can use this calendar!

CalendarView cView = new CalendarView(start, end, int.MaxValue);

cView.PropertySet = new PropertySet(AppointmentSchema.Subject, AppointmentSchema.Start, AppointmentSchema.End, AppointmentSchema.Duration, AppointmentSchema.LastModifiedName, AppointmentSchema.Organizer, AppointmentSchema.Categories);

FindItemsResults<Appointment> appointments = calendar.FindAppointments(cView);

With something like that ;D




回答2:


If the calendar is actually not in any particular mailbox, then it should be in a public folder, and you should look in a subfolder WellKnownFolderName.PublicFoldersRoot.

Otherwise, please tell where exactly does it appear in Outlook folders hierarchy.



来源:https://stackoverflow.com/questions/16154802/accessing-a-resource-calendar-with-no-mailbox-via-ews-and-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!