c# Outlook通过使用EWS获取其他用户的公共约会

本文关键字:用户 其他 约会 获取 EWS Outlook | 更新日期: 2023-09-27 18:16:19

我目前正在尝试检索Outlook(与Exchange2013)中用户日历的公共约会到稍后要显示的数据集。
下面是到目前为止的相关代码:

ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2013);
service.AutodiscoverUrl("mail@mycompany.com", RedirectionCallback);
DateTime reportDate = dateTimePicker1.Value;
DateTime startDate = new DateTime(reportDate.Year, reportDate.Month, reportDate.Day, 0, 0, 1);
DateTime endDate = startDate.AddHours(23);
endDate = endDate.AddMinutes(59);
CalendarFolder calendar = CalendarFolder.Bind(service, new FolderId(WellKnownFolderName.Calendar, "somemail@mycompany.com"));
CalendarView cView = new CalendarView(startDate, endDate);
cView.PropertySet = new PropertySet(AppointmentSchema.Subject, AppointmentSchema.Start, AppointmentSchema.End, AppointmentSchema.Location);
// get appointment collection
FindItemsResults<Appointment> appointments = calendar.FindAppointments(cView);
// transfer to DataSet
DataSet1.Tables[0].Rows.Clear();
int i = 0;
foreach (Appointment a in appointments) {
    DataSet1.Tables[0].Rows.Add(
        i++.ToString(),
        a.Subject.ToString(),
        a.Start.ToString(),
        a.End.ToString(),
        a.Location.ToString());
}

行显示了一个异常

CalendarFolder日历= CalendarFolder。绑定(service, new FolderId)日历,"somemail@mycompany.com");

你知道我哪里做错了吗?或者是否有完全不同的方法来解决我的问题?

c# Outlook通过使用EWS获取其他用户的公共约会

您用来连接交换服务器的帐户没有权限读取somemail@mycompany.com的邮箱。尝试为该帐户获得超级用户权限。希望这是有用的。

相关文章: