Quick Start With iCalendar API

iCalendar API

Aspose.Email Cloud API supports working with iCalendar files. You can use our API to read, edit and save iCalendar (.ics) files. Also, you can convert them to AlternateView and add them to email messages.

Our SDKs support two different ways of operating with iCalendar files using MapiCalendarDto and CalendarDto. This tutorial shows how to use CalendarDto.

Create Calendar File Object and Save It to Storage

CalendarDto object contains all information about an appointment including attendees, start date, end date, description and etc.

First, let’s create a CalendarDto object and save it to Storage.

To save a CalendarDto to Storage use SaveAsync from CalendarApi. This method requires 1 parameter —  CalendarSaveRequest, which is a request model for this operation. 

CalendarSaveRequest requires 3 parameters:

  • Format — Calendar file format (Ics or Msg).
  • StorageFileStorageFileLocation object that determines iCalendar file location on storage.
  • ValueCalendarDto object to save.

How to create a CalendarDto object and save it to the Storage?

Download iCalendar File From Storage

You can find the saved file on Aspose.Cloud Dashboard, or download it using SDK.

To download a file from the storage use DownloadFileAsync from FileApi. This method requires 1 parameter — DownloadFileRequest, which is a request for this operation.

DownloadFileRequest has 3 parameters:

  • Path — File path e.g. “/folder/file.ext”.
  • StorageName — Storage name.
  • VersionId [optional] — File version ID to download.

How to download iCalendar file from the Storage?

Get Calendar File From Storage as CalendarDto Object

Let’s get this file from storage as a CalendarDto object.

To get a calendar file from Storage use GetAsync  from CalendarApi. This method requires 1 parameter —  CalendarGetRequest, which is a request for this operation.

CalendarGetRequest has 3 parameters:

  • FileName — iCalendar file name in storage.
  • Folder — Path to the folder in storage.
  • Storage — Storage name.

How to get a file from the Storage as a CalendarDto object?

You can change model fields and save it again. The file will be rewritten if you don’t change file name and location.

Convert Calendar Object to AlternateView

We also provide API methods for converting CalendarDto to an AlternateView. AlternateView can be added to EmailDto, which can be saved as EML file or sent using a built-in email client.

To convert a CalendarDto object to AlternateView use AsAlternateAsync from CalendarApi. This method has 3 parameters:

  • Value — iCalendar document model.
  • Action — iCalendar actions. Enum, available values: Create, Update, Cancel.
  • SequenceId — iCalendar sequence id.

How to convert CalendarDto to an AlternateView?

Get a List of iCalendar Files From One Folder

You can get a list of iCalendar files stored in one folder on storage using a single API request. Files will be filtered by “.ics” extension and read to list of CalendarDto object. The method supports pagination.

To get a list of iCalendar files use GetListAsync from CalendarApi. This method requires 1 parameter — CalendarGetListRequest, which is a request for this operation.

CalendarGetListRequest has 4 parameters:

  • Folder — Path to the folder in storage.
  • ItemsPerPage — Count of items on page.
  • PageNumber — Page number.
  • Storage — Storage name.

How to get a list of iCalendar files stored in one folder?

More Tutorials

See more Aspose Email tutorials: