Время, проведенное на собраниях с использованием веб-служб Exchange
Я пытаюсь выяснить, сколько времени мы проводим на собраниях в качестве подразделения (~100 человек). Для простоты мы можем считать все часы работы такими же, как на собраниях. Однако я не могу понять, как это сделать, и я надеялся, что у кого-то есть идея
1 ответ
Вам нужно показать, какой код вы пробовали и какие ошибки вы получаете, если таковые имеются. Тем не менее, есть примеры использования EWS API для такого рода вещей в Интернете. За
Примеры идей для работы с вами:
Получение встреч с помощью управляемого API EWS В следующем примере кода показано, как использовать управляемый API EWS для получения встреч пользователя, которые попадают между указанным временем начала и окончания.
// 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();
}
Базовый сценарий Powershell для отображения встреч из календаря с помощью управляемого API EWS
$MailboxName = 'SomeUserEmailALias'
$StartDate = Get-Date
$EndDate = (Get-Date).AddDays(7)
$DllPath = 'C:\Program Files\Microsoft\Exchange\Web Services\1.2\Microsoft.Exchange.WebServices.dll'
[void][Reflection.Assembly]::LoadFile($DllPath)
$Service = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService([Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2010)
$Service.AutodiscoverUrl($MailboxName)
$FolderID = New-Object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Calendar,$MailboxName)
$CalendarFolder = [Microsoft.Exchange.WebServices.Data.CalendarFolder]::Bind($Service,$FolderID)
$Calendarview.PropertySet = New-Object Microsoft.Exchange.WebServices.Data.PropertySet([Microsoft.Exchange.WebServices.Data.BasePropertySet]::FirstClassProperties)
$CalendarResult = $CalendarFolder.FindAppointments($CalendarView)
foreach ($Appointment in $CalendarResult.Items)
{
$Propset = New-Object Microsoft.Exchange.WebServices.Data.PropertySet([Microsoft.Exchange.WebServices.Data.BasePropertySet]::FirstClassProperties)
$Appointment.load($Propset)
New-Object -TypeName PSObject -Property @{
Appointment = $Appointment.Subject.ToString()
Start = $Appointment.Start.ToString()
End = $Appointment.End.ToString()
Organizer = $Appointment.Organizer.ToString()
}
}
https://gsexdev.blogspot.com/2009/11/basic-powershell-script-to-show.html
[Powershell script EWS] Работа с элементами календаря с использованием управляемого API EWS
$Folderid= new-object Microsoft.Exchange.WebServices.Data.FolderId `
([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Calendar,$MailboxToImpersonate)
$cal=[Microsoft.Exchange.WebServices.Data.Folder]::Bind($service,$Folderid)
$StartDate =(Get-Date)
$EndDate =(get-date).AddDays(7)
$CalendarView = New-Object Microsoft.Exchange.WebServices.Data.CalendarView `
($StartDate,$EndDate,$itemsView)
$findCalItems = $service.FindAppointments($Cal.Id,$CalendarView)
param
(
$mailbox="SomeUserEmailALias",
$itemsView=1000,
$userName=$cred.UserName,
$password=$cred.GetNetworkCredential().password,
$StartDate =(Get-Date),
$EndDate =(get-date).AddDays(7) # find meeting upto next 7 days.
)
#set EWS URL and Web Service DLL file location path below.
$uri=[system.URI] "https://outlook.office365.com/ews/exchange.asmx"
$dllpath = "C:\Program Files\Microsoft\Exchange\Web Services\2.2\Microsoft.Exchange.WebServices.dll"
Import-Module $dllpath
#Set Exchange Version
$ExchangeVersion = [Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2010_SP2
$service = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService($ExchangeVersion)
$service.Credentials = New-Object Microsoft.Exchange.WebServices.Data.WebCredentials -ArgumentList $userName, $password
$service.url = $uri
$service.ImpersonatedUserId = New-Object Microsoft.Exchange.WebServices.Data.ImpersonatedUserId `
([Microsoft.Exchange.WebServices.Data.ConnectingIdType]::SMTPAddress,$mailbox);
$Folderid= new-object Microsoft.Exchange.WebServices.Data.FolderId `
([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Calendar,$mailbox)
$cal=[Microsoft.Exchange.WebServices.Data.Folder]::Bind($service,$Folderid)
#Define the calendar view
$CalendarView = New-Object Microsoft.Exchange.WebServices.Data.CalendarView($StartDate,$EndDate,$itemsView)
$findCalItems = $service.FindAppointments($Cal.Id,$CalendarView)
$report = $findCalItems | Select Start,End,Duration,AppointmentType,Subject,Location,
Organizer,DisplayTo,DisplayCC,HasAttachments,IsReminderSet,ReminderDueBy
$report | Export-Csv $($mailbox + "-Meetings.csv") -NoTypeInformation
https://www.linkedin.com/pulse/powershell-script-ews-working-calendar-items-using-managed-chauhan
Скрипт EWS для экспорта информации календаря в файл CSV.
.Synopsis:
Script which creates a function "Export-CalendarInformation" which can be used to export details of each calendar items to a CSV file.
. Description:
Using EWS API and authorized credentials (can use an account with application impersonation permission) this script exports below details of each calendar item in a mailbox calendar to CSV file. This script will return
StartTime, EndTime, Duration, Type, Subject, Location, Organizer, Attendees, AppointmentState, Notes, HasAttachments, IsReminderSet
https://gallery.technet.microsoft.com/EWS-Script-to-Export-c76a0ad4