Working with Calendar Items on Exchange Server
Sending Meeting Requests
This article shows how to send a meeting request to multiple recipients using Exchange Web Services and Aspose.Email.
- Create a meeting request using the Appointment class and set the location, time and attendees.
- Create an instance of the MailMessage class and set the appointment using the MailMessage.AddAlternateView() method.
- Connect to the Exchange Server and send the meeting request using the Send(MailMessage) method.
The EWSClient class can be used to connect to an Exchange Server with Exchange Web Services (EWS) support. For this to work, the server has to be Exchange Server 2007 or later. The following code snippet shows you how to use EWS to send meeting requests.
Working with Calendar Items using EWS
Aspose.Email provides the capability to add, update and cancel appointments using Exchange Web Service (EWS) client. The IEWSClient CreateAppointment, UpdateAppointment, and CancelAppointment methods allow manipulating calendar items using EWS. This article provides a detailed code sample of working with Calendar items. The following code sample shows how to:
- Create an appointment.
- Update an appointment.
- Delete/Cancel an appointment.
Listing Appointments with Paging Support
The ListAppointments method exposed by the IEWSClient API retrieves the complete list of appointments from the Exchange server. This may take time if there is a large number of appointments on the Exchange Server. The API provides overloaded methods of ListAppointments method that gives paging support to the operation. This can be used in different combinations with the querying feature as well. The following overloaded methods are available to list appointments from Exchange Server with Paging support.
- AppointmentCollection IEWSClient.ListAppointments(int itemsPerPage).
- AppointmentCollection IEWSClient.ListAppointments(string folderUri, int itemsPerPage).
- AppointmentCollection IEWSClient.ListAppointments(MailQuery query, int itemsPerPage).
- AppointmentCollection IEWSClient.ListAppointments(string folderUri, MailQuery query, int itemsPerPage).
- AppointmentCollection IEWSClient.ListAppointments(int itemsPerPage, int itemOffset).
- AppointmentCollection IEWSClient.ListAppointments(string folderUri, int itemsPerPage, int itemOffset).
- AppointmentCollection IEWSClient.ListAppointments(MailQuery query, int itemsPerPage, int itemOffset).
- AppointmentCollection IEWSClient.ListAppointments(string folderUri, MailQuery query, int itemsPerPage, int itemOffset).
The following code snippet shows you how to list appointments with paging support.
Adding Event to Secondary Calendar folder on Exchange Server
Aspose.Email API lets you create a secondary Calendar folder on Exchange Server using the IEWSClient. Appointments can then be added, updated or canceled from the secondary calendar using the CreateAppointment, UpdateAppointment and CancelAppointment methods. The following API methods and properties are used in the code samples below to show the functionality of this feature. Please note that this feature is supported by Aspose.Email for .NET 6.5.0 onwards.
- Method IEWSClient.CancelAppointment(Appointment, String).
- Method IEWSClient.CancelAppointment(String, String).
- Method IEWSClient.CreateAppointment(Appointment, String).
- Method IEWSClient.CreateFolder(String, String, ExchangeFolderPermissionCollection, String).
- Method IEWSClient.FetchAppointment(String, String).
- Method IEWSClient.UpdateAppointment(Appointment, String).
- Property IEWSClient.CurrentCalendarFolderUri.
The following code snippet shows you how to add an event to the secondary calendar folder on the exchange server.
Sharing Calendar Invitation
Microsoft Exchange server provides the capability to share calendars by sending calendar invitations to other users, registered on the same Exchange server. Aspose.Email API provides the same capability by allowing to share the calendar using the EWS API.
Retrieving Extended Attributes Information from Calendar Items
Returning the Recurring Calendar Items Within the Specified Date Range
EWSClient supports the return of the recurring calendar items within the range specified by StartDate and EndDate. AppointmentQueryBuilder.SetCalendarView method is used to define a specific date range and limit the number of returned appointments to retrieve relevant information. By setting the following parameters you can retrieve the appointments matching the specified criteria.
startDate: The start date of the calendar view. Appointments starting from this date will be included in the query result.
endDate: The end date of the calendar view. Appointments ending before or on this date will be included in the query result.
maxEntriesReturned: The maximum number of appointments to be returned in the query result. The value of -1 indicates that there is no specific limit.
ExchangeQueryBuilder builder = new ExchangeQueryBuilder(); builder.Appointment.SetCalendarView(DateTime.Now, DateTime.Now.AddMonths(1), -1); Appointment appointments = client.ListAppointments(builder.GetQuery());