简体   繁体   English

无需验证即可获取Office365电子邮件的日历

[英]Get calendars of office365 email without authentication

I want to get list of events of particular users lets say user@company1.com , user@company2.com which uses office365 accounts. 我想获取特定用户的事件列表,比如说使用office365帐户的user@company1.com和user@company2.com。

I need to retrive user@company2.com calendar with out login. 我需要在未登录的情况下检索user@company2.com日历。 My application will be like listing my available timings for my clients , so that they can select my free time and will schedule meeting with me. 我的申请就像列出客户的可用时间,以便他们选择我的空闲时间并安排与我会面。 I need to filter the already scheduled events from my list... Is there any example code for getting calendar events without login?? 我需要从列表中过滤已经安排好的事件...是否有示例代码可以在不登录的情况下获取日历事件?

I tried office365 multi-tenant application which will gives sample code for getting calendar events only after login. 我尝试了office365多租户应用程序,该应用程序将提供示例代码,以便仅在登录后获取日历事件。 I need it with out authentication. 我不需要身份验证就可以了。 Please help me on this. 请帮我。

Trying to access the O365 information without authentication is impossible , either user authentication or app authentication will be required . 试图在没有身份验证的情况下访问O365信息是不可能的,将需要用户身份验证或应用程序身份验证。 In your scenario ,you may need app authentication . 在您的情况下,您可能需要应用程序身份验证。 You could try to build Daemon or Service Apps using client credential grant flow as described in this blog , the service app that requires admin consent, but is authorized to access any mailbox/calendar information in your Office 365 tenant. 您可以尝试使用此博客中描述的客户端凭据授予流来构建Daemon或Service Apps,该博客是需要管理员同意但被授权访问Office 365租户中任何邮箱/日历信息的服务应用程序。

Another choice is to use EWS Managed API, you could get free/busy information of a user and suggested meeting times by using the EWS Managed API : 另一个选择是使用EWS托管API,通过使用EWS托管API,您可以获得用户的忙/闲信息和建议的开会时间:

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

And an existing Office add-in support on Outlook: 以及Outlook上的现有Office加载项支持:

https://findtime.microsoft.com/ https://findtime.microsoft.com/

Finally I tried to use the free/busy code. 最后,我尝试使用忙/闲代码。 My code is as follows... I am following this procedure but I don't know if it is correct or not. 我的代码如下...我正在执行此过程,但是我不知道它是否正确。 I have a Microsoft Office 365 account, and by passing credentials silently, I am creating Exchange Server service. 我有一个Microsoft Office 365帐户,并且通过静默传递凭据,正在创建Exchange Server服务。 After that i am passing different domain attendee information as ORGANIZER and REQUIRED as follows. 之后,我将按照以下方式传递不同的域参与者信息,如ORGANIZER和REQUIRED。 But it is returning all values not skipping any scheduled meetings for those users. 但是,它返回的所有值不会跳过那些用户的任何预定会议。

Lets assume user1@domain.com is ORGANIZER and user2@anotherdomain.com is REQUIRED for meeting . 让我们假设user1@domain.com是ORGANIZER,而user2@anotherdomain.com是需要开会的。 User1 have meeting scheduled at 7:00-7:30pm on daily basis but when I executed the following script it shows me 7:00-7:30pm as available for meeting. User1的会议安排在每天的7:00-7:30pm进行,但是当我执行以下脚本时,它显示我7:00-7:30pm可以进行会议。 It supposed to block that time. 它应该阻止那个时间。

Can you suggest some changes to code and am I proceeding in the correct way? 您可以建议对代码进行一些更改,我是否以正确的方式进行?

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++;
    }

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

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