我想获取特定用户的事件列表,比如说使用office365帐户的[email protected]和[email protected]。
我需要在未登录的情况下检索[email protected]日历。我的申请就像列出客户可用的时间安排一样,以便他们可以选择我的空闲时间并安排与我开会的时间。我需要从列表中过滤已经安排好的事件...是否有示例代码可以在不登录的情况下获取日历事件?
我尝试了office365多租户应用程序,该应用程序将提供示例代码,以便仅在登录后获取日历事件。我不需要身份验证就可以了。请帮我。
最后,我尝试使用忙/闲代码。我的代码如下...我正在执行此过程,但是我不知道它是否正确。我有一个Microsoft Office 365帐户,并且通过静默传递凭据,正在创建Exchange Server服务。之后,我将按照以下方式传递不同的域参加者信息,如ORGANIZER和REQUIRED。但是,它返回的所有值不会跳过那些用户的任何预定会议。
假设[email protected]是ORGANIZER,而[email protected]是进行会议所必需的。User1的会议安排在每天的7:00-7:30pm进行,但是当我执行以下脚本时,它显示我7:00-7:30pm可以进行会议。它应该阻止那个时间。
您可以建议对代码进行一些更改,我是否以正确的方式进行?
private static void GetSuggestedMeetingTimes(ExchangeService service)
{
List<AttendeeInfo> attendees = new List<AttendeeInfo>();
attendees.Add(new AttendeeInfo()
{
SmtpAddress = "[email protected]",
AttendeeType = MeetingAttendeeType.Organizer
});
attendees.Add(new AttendeeInfo()
{
SmtpAddress = "[email protected]",
AttendeeType = MeetingAttendeeType.Required
});
// Specify options to request free/busy information and suggested meeting times.
AvailabilityOptions availabilityOptions = new AvailabilityOptions();
availabilityOptions.GoodSuggestionThreshold = 49;
availabilityOptions.MaximumNonWorkHoursSuggestionsPerDay = 0;
availabilityOptions.MaximumSuggestionsPerDay = 40;
// Note that 60 minutes is the default value for MeetingDuration, but setting it explicitly for demonstration purposes.
availabilityOptions.MeetingDuration = 30;
availabilityOptions.MinimumSuggestionQuality = SuggestionQuality.Good;
availabilityOptions.DetailedSuggestionsWindow = new TimeWindow(DateTime.Now.AddDays(1), DateTime.Now.AddDays(2));
availabilityOptions.RequestedFreeBusyView = FreeBusyViewType.FreeBusy;
// Return free/busy information and a set of suggested meeting times.
// This method results in a GetUserAvailabilityRequest call to EWS.
GetUserAvailabilityResults results = service.GetUserAvailability(attendees,
availabilityOptions.DetailedSuggestionsWindow,
AvailabilityData.FreeBusyAndSuggestions,
availabilityOptions);
// Display suggested meeting times.
Console.WriteLine("Availability for {0} and {1}", attendees[0].SmtpAddress, attendees[1].SmtpAddress);
Console.WriteLine();
foreach (Suggestion suggestion in results.Suggestions)
{
Console.WriteLine("Suggested date: {0}\n", suggestion.Date.ToShortDateString());
Console.WriteLine("Suggested meeting times:\n");
foreach (TimeSuggestion timeSuggestion in suggestion.TimeSuggestions)
{
Console.WriteLine("\t{0} - {1}\n",
timeSuggestion.MeetingTime.ToShortTimeString(),
timeSuggestion.MeetingTime.Add(TimeSpan.FromMinutes(availabilityOptions.MeetingDuration)).ToShortTimeString());
}
}
int i = 0;
// Display free/busy times.
foreach (AttendeeAvailability availability in results.AttendeesAvailability)
{
Console.WriteLine("Availability information for {0}:\n", attendees[i].SmtpAddress);
foreach (CalendarEvent calEvent in availability.CalendarEvents)
{
Console.WriteLine("\tBusy from {0} to {1} \n", calEvent.StartTime.ToString(), calEvent.EndTime.ToString());
}
i++;
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句