特定日历EWS(C#)的访问会议

时间:2017-04-25 07:03:30

标签: c# exchangewebservices

我正在构建一个从Exchange访问会议的应用程序。我在他们的EWS文档中使用了Microsoft提供的代码。问题是我需要访问特定日历。比方说,我创建了两个日历,除了默认日历。当我使用此代码访问会议时,我只从默认日历中获取会议。我想访问特定日历中的会议。我怎么能这样做?

感谢您的帮助。

 // Initialize values for the start and end times, and the number of appointments to retrieve.
            DateTime startDate = DateTime.Now;
            DateTime endDate = startDate.AddDays(30);
            const int NUM_APPTS = 5;

            // Initialize the calendar folder object with only the folder ID. 
            CalendarFolder calendar = CalendarFolder.Bind(service, WellKnownFolderName.Calendar, new PropertySet());

            // Set the start and end time and number of appointments to retrieve.
            CalendarView cView = new CalendarView(startDate, endDate, NUM_APPTS);

            // Limit the properties returned to the appointment's subject, start time, and end time.
            cView.PropertySet = new PropertySet(AppointmentSchema.Subject, AppointmentSchema.Start, AppointmentSchema.End);

            // Retrieve a collection of appointments by using the calendar view.
            FindItemsResults<Appointment> appointments = calendar.FindAppointments(cView);

            Console.WriteLine("\nThe first " + NUM_APPTS + " appointments on your calendar from " + startDate.Date.ToShortDateString() + 
                              " to " + endDate.Date.ToShortDateString() + " are: \n");
            
            foreach (Appointment a in appointments)
            {
                Console.Write("Subject: " + a.Subject.ToString() + " ");
                Console.Write("Start: " + a.Start.ToString() + " ");
                Console.Write("End: " + a.End.ToString());
                Console.WriteLine();
            }

1 个答案:

答案 0 :(得分:0)

我认为您的问题是您使用的是WellKnownFolderName.Calendar:

 <GoogleMapReact
    defaultCenter={this.props.center}
    defaultZoom={this.props.zoom}
    style={height: '400px', width: '400px'}
  >

相反,您应该使用您创建的日历的FolderId。要获取文件夹(日历)的ID,您可以使用与此类似的代码(在答案中找到:https://stackoverflow.com/a/24133821/1037864

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

从fld.Id获取值并使用而不是WellKnownFolderName.Calendar。

(我现在没有可用的Exchange服务器试试这个,但我希望你明白我的代码是正确的。)