There is an example of getting FreeBusy from an exchange server from VB.NET. I use this to coordinate calendar invites on an external DMZ for outside vendors to streamline meeting request.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
Imports Microsoft.Exchange.WebServices.Data Public Class Form1 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim Server As New Microsoft.Exchange.WebServices.Data.ExchangeService(ExchangeVersion.Exchange2010) Server.Url = New System.Uri("https://Webmail/EWS/Exchange.asmx") GetSuggestedMeetingTimesAndFreeBusyInfo(Server) End Sub Private Shared Sub GetSuggestedMeetingTimesAndFreeBusyInfo(ByVal service As ExchangeService) Dim attendees As List(Of AttendeeInfo) = New List(Of AttendeeInfo)() attendees.Add(New AttendeeInfo() With { .SmtpAddress = "First@Email.com", .AttendeeType = MeetingAttendeeType.Organizer }) attendees.Add(New AttendeeInfo() With { .SmtpAddress = "Second@Email.com", .AttendeeType = MeetingAttendeeType.Required }) Dim availabilityOptions As AvailabilityOptions = New AvailabilityOptions() availabilityOptions.GoodSuggestionThreshold = 49 availabilityOptions.MaximumNonWorkHoursSuggestionsPerDay = 0 availabilityOptions.MaximumSuggestionsPerDay = 2 availabilityOptions.MeetingDuration = 60 availabilityOptions.MinimumSuggestionQuality = SuggestionQuality.Good availabilityOptions.DetailedSuggestionsWindow = New TimeWindow(DateTime.Now.AddDays(1), DateTime.Now.AddDays(7)) availabilityOptions.RequestedFreeBusyView = FreeBusyViewType.FreeBusy Dim results As GetUserAvailabilityResults = service.GetUserAvailability(attendees, availabilityOptions.DetailedSuggestionsWindow, AvailabilityData.FreeBusyAndSuggestions, availabilityOptions) Console.WriteLine("Availability for {0} and {1}", attendees(0).SmtpAddress, attendees(1).SmtpAddress) Console.WriteLine() For Each suggestion As Suggestion In results.Suggestions Console.WriteLine("Suggested date: {0}" & vbLf, suggestion.Date.ToShortDateString()) Console.WriteLine("Suggested meeting times:" & vbLf) For Each timeSuggestion As TimeSuggestion In suggestion.TimeSuggestions Console.WriteLine(vbTab & "{0} - {1}" & vbLf, timeSuggestion.MeetingTime.ToShortTimeString(), timeSuggestion.MeetingTime.Add(TimeSpan.FromMinutes(availabilityOptions.MeetingDuration)).ToShortTimeString()) Next Next Dim i As Integer = 0 For Each availability As AttendeeAvailability In results.AttendeesAvailability Console.WriteLine("Availability information for {0}:" & vbLf, attendees(i).SmtpAddress) For Each calEvent As CalendarEvent In availability.CalendarEvents Console.WriteLine(vbTab & "Busy from {0} to {1} " & vbLf, calEvent.StartTime.ToString(), calEvent.EndTime.ToString()) Next i += 1 Next End Sub End Class |
Availability for first@email.com and second@email.com Suggested date: 8/20/2019 Suggested meeting times:
1 2 3 |
10:00 AM - 11:00 AM 10:30 AM - 11:30 AM |
Suggested date: 8/21/2019 Suggested meeting times:
1 2 3 |
9:00 AM - 10:00 AM 10:30 AM - 11:30 AM |
Suggested date: 8/22/2019 Suggested …