无需身份验证即可获取office365电子邮件的日历

Get calendars of office365 email without authentication

我想获取特定用户的事件列表让我们说 user@company1.com , user@company2.com 使用 office365 帐户。

我需要在未登录的情况下检索 user@company2.com 日历。我的申请就像为我的客户列出我的可用时间,以便他们可以 select 我的空闲时间并安排与我会面。我需要从我的列表中过滤已安排的事件...是否有无需登录即可获取日历事件的示例代码?

我尝试了 office365 多租户应用程序,它将提供仅在登录后获取日历事件的示例代码。我需要它而无需身份验证。请帮我解决这个问题。

试图在没有身份验证的情况下访问 O365 信息是不可能的,将需要用户身份验证或应用程序身份验证。在您的场景中,您可能需要应用程序身份验证。您可以尝试使用此 blog 中所述的客户端凭据授予流程构建守护程序或服务应用程序,该服务应用程序需要管理员同意,但有权访问您的 Office 365 租户中的任何 mailbox/calendar 信息。

另一种选择是使用 EWS Managed API,您可以通过使用 EWS Managed API 获取 free/busy 用户信息和建议的会议时间 :

https://msdn.microsoft.com/en-us/library/office/dn643673(v=exchg.150).aspx

现有 Office add-in 对 Outlook 的支持:

https://findtime.microsoft.com/

最后我尝试使用 free/busy 代码。我的代码如下...我正在按照此过程进行操作,但我不知道它是否正确。我有一个 Microsoft Office 365 帐户,通过静默传递凭据,我正在创建 Exchange Server 服务。之后,我将不同的域与会者信息作为 ORGANIZER 和 REQUIRED 传递,如下所示。但它会返回所有值,不会跳过为这些用户安排的任何会议。

假设 user1@domain.com 是组织者并且 user2@anotherdomain.com 是开会所必需的。 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 = "user1@mydomain.com",
        AttendeeType = MeetingAttendeeType.Organizer
    });

    attendees.Add(new AttendeeInfo()
    {
        SmtpAddress = "user2@anotherdomain.com",
        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++;
    }