繁体   English   中英

使用一个帐户从不同房间获取约会

[英]Get appointments from different rooms with one account

我有一个交换帐户,可以访问我们所有房间的电子邮件帐户。
我需要使用此“管理员帐户”获取每个房间的所有计划约会。

一开始,我为每个帐户设置了登录名。
我将必要的信息存储在对象中,然后使用以下代码获取所有需要的数据。

string roomName = rooms[i].RoomName;

ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);

service.Timeout = 5000;

service.Credentials = new NetworkCredential(rooms[i].AccountName + "@company.com", rooms[i].AccountPassword);

service.AutodiscoverUrl(rooms[i].AccountName + "@company.com");


DateTime startDate = DateTime.Now;
DateTime endDate = startDate.AddDays(7);
const int NUM_APPTS = 280;

Console.WriteLine("Start binding calendar objects");
//init calender folder object
CalendarFolder calendar = CalendarFolder.Bind(service, WellKnownFolderName.Calendar, new PropertySet());

Console.WriteLine("Start setting start and end time and number of appointments to retrieve");
//set start and end time and number of appointments to retrieve.
CalendarView cView = new CalendarView(startDate, endDate, NUM_APPTS);

Console.WriteLine("limit the properties");
//limit the properties returned to subject(name of the person who booked the room, name of the room, start and end time(datetime) of the meeting
cView.PropertySet = new PropertySet(AppointmentSchema.Organizer, AppointmentSchema.Start, AppointmentSchema.End, AppointmentSchema.Subject);

//retrieve Collection of appointments by using the calendar view
FindItemsResults<Appointment> appointments = calendar.FindAppointments(cView);

将此代码与admin帐户一起使用只会返回任何内容。

我尝试使用以下代码获取此帐户的所有房间

    System.Collections.ObjectModel.Collection<EmailAddress> myRoomAddresses = service.GetRooms("roomsync@company.com");

但这仅返回ServiceResponseException:未找到任何内容。

有人知道仅使用admin帐户获取所有房间和约会的方法吗?

您应该使用FolderId重载来指定要访问的邮箱,否则您的代码将始终只访问您使用的凭据的日历文件夹,例如,替换行

CalendarFolder calendar = CalendarFolder.Bind(service, WellKnownFolderName.Calendar, new PropertySet());

FolderId CalendarFolderIdVal = new FolderId(WellKnownFolderName.Calendar,rooms[i].AccountName + "@company.com");
CalendarFolder calendar = CalendarFolder.Bind(service, CalendarFolderIdVal, new PropertySet());

您只需使用服务帐户的电子邮件地址进行一次自动发现。

System.Collections.ObjectModel.Collection<EmailAddress> myRoomAddresses = service.GetRooms("roomsync@company.com");

如果此会议室列表存在并已填充,它将仅返回该列表中会议室的电子邮件地址。 该错误表明列表不存在。

干杯格伦

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM