# IcsDocument

A standalone iCalendar stream containing one or more VCALENDAR objects.

Class 

`OfficeIMO.Email`

**Namespace**

`OfficeIMO.Email`

**Assembly**

`OfficeIMO.Email`

**Source revision**

`be6c300e4ab1` with working tree changes

**Source**

[IcsDocument.cs:6](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Email/Calendar/IcsDocument.cs#L6)

**Modifiers**

sealed

A standalone iCalendar stream containing one or more VCALENDAR objects.

## Inheritance

- object
- IcsDocument

## Guides & Samples

Authored walkthroughs and practical samples linked to this API.

- [Read and Edit Calendars, Contacts, and Outlook Items](/docs/email/calendars-and-contacts/) Guide
  
  Read and update iCalendar (ICS), vCalendar, and vCard files, and expand Outlook appointment recurrence with OfficeIMO.Email.
- [Read, Write, and Convert Email and Outlook Files](/docs/email/) Guide
  
  OfficeIMO.Email reads and writes EML, MSG, OFT, TNEF, PST, OST, OLM, mbox, calendar and contact files in .NET, with no Outlook installed.

## Usage

Explore 6 API references to this type

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

### Returned or exposed by 6

- Property [EmailDataOpenResult.Calendar](/api/email/officeimo-email-data-emaildataopenresult/#property-calendar)
- Method [EmailPortableContentCollection.ToCalendars](/api/email/officeimo-email-emailportablecontentcollection/#method-tocalendars-collections-generic-ienumerable-officeimo-email-emaildocument-officeimo-email-emailportablecontentexportoptions-int32-threading-cancellationtoken)
- Method [EmailPortableContentExport.ToCalendar](/api/email/officeimo-email-emailportablecontentexport/#method-tocalendar-officeimo-email-emaildocument-officeimo-email-emailportablecontentexportoptions-threading-cancellationtoken)
- Method [IcsDocument.Load](/api/email/officeimo-email-icsdocument/#method-load-byte-officeimo-email-contentlinereaderoptions)
- Method [IcsDocument.LoadAsync](/api/email/officeimo-email-icsdocument/#method-loadasync-string-officeimo-email-contentlinereaderoptions-threading-cancellationtoken)
- Method [IcsDocument.Parse](/api/email/officeimo-email-icsdocument/#method-parse-string-officeimo-email-contentlinereaderoptions)

Filter members 

Show inherited

## Constructors

`public IcsDocument(string productId = "-//OfficeIMO//OfficeIMO.Email//EN")` [#](#constructor-ctor-string)

[IcsDocument.cs:6](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Email/Calendar/IcsDocument.cs#L6)

Creates a document with one RFC 5545 VCALENDAR object.

Parameters

**productId string = "-//OfficeIMO//OfficeIMO.Email//EN" optional**

## Methods

`public ContentLineComponent AddCalendar()` [#](#method-addcalendar)

[IcsDocument.cs:24](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Email/Calendar/IcsDocument.cs#L24)

Adds an empty VCALENDAR root.

Returns

`ContentLineComponent`

`public IEnumerable<ContentLineComponent> GetComponents(string name, bool recursive = true)` [#](#method-getcomponents-string-boolean)

Enumerates matching components across every calendar.

Parameters

**name string required**

**recursive bool = true optional**

Returns

`IEnumerable<ContentLineComponent>`

Load 3 overloads

`public static IcsDocument Load(byte[] bytes, ContentLineReaderOptions? options = null)` [#](#method-load-byte-officeimo-email-contentlinereaderoptions)

[IcsDocument.cs:44](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Email/Calendar/IcsDocument.cs#L44)

Loads an iCalendar stream from memory.

Parameters

**bytes byte[] required**

**options OfficeIMO.Email.ContentLineReaderOptions? = null optional**

Returns

`IcsDocument`

`public static IcsDocument Load(string filePath, ContentLineReaderOptions? options = null, CancellationToken cancellationToken = default)` [#](#method-load-string-officeimo-email-contentlinereaderoptions-threading-cancellationtoken)

[IcsDocument.cs:50](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Email/Calendar/IcsDocument.cs#L50)

Loads an iCalendar file.

Parameters

**filePath string required**

**options OfficeIMO.Email.ContentLineReaderOptions? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`IcsDocument`

`public static IcsDocument Load(Stream stream, ContentLineReaderOptions? options = null, CancellationToken cancellationToken = default)` [#](#method-load-io-stream-officeimo-email-contentlinereaderoptions-threading-cancellationtoken)

[IcsDocument.cs:57](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Email/Calendar/IcsDocument.cs#L57)

Loads from a caller-owned stream without closing it.

Parameters

**stream System.IO.Stream required**

**options OfficeIMO.Email.ContentLineReaderOptions? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`IcsDocument`

LoadAsync 2 overloads

`public static async Task<IcsDocument> LoadAsync(string filePath, ContentLineReaderOptions? options = null, CancellationToken cancellationToken = default)` [#](#method-loadasync-string-officeimo-email-contentlinereaderoptions-threading-cancellationtoken)

Asynchronously loads an iCalendar file.

Parameters

**filePath string required**

**options OfficeIMO.Email.ContentLineReaderOptions? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`Task<IcsDocument>`

`public static async Task<IcsDocument> LoadAsync(Stream stream, ContentLineReaderOptions? options = null, CancellationToken cancellationToken = default)` [#](#method-loadasync-io-stream-officeimo-email-contentlinereaderoptions-threading-cancellationtoken)

Asynchronously loads from a caller-owned stream without closing it.

Parameters

**stream System.IO.Stream required**

**options OfficeIMO.Email.ContentLineReaderOptions? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`Task<IcsDocument>`

`public static IcsDocument Parse(string text, ContentLineReaderOptions? options = null)` [#](#method-parse-string-officeimo-email-contentlinereaderoptions)

[IcsDocument.cs:39](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Email/Calendar/IcsDocument.cs#L39)

Parses an iCalendar stream from text.

Parameters

**text string required**

**options OfficeIMO.Email.ContentLineReaderOptions? = null optional**

Returns

`IcsDocument`

Save 2 overloads

`public void Save(string filePath, ContentLineWriterOptions? options = null)` [#](#method-save-string-officeimo-email-contentlinewriteroptions)

[IcsDocument.cs:94](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Email/Calendar/IcsDocument.cs#L94)

Atomically saves this document to a file.

Parameters

**filePath string required**

**options OfficeIMO.Email.ContentLineWriterOptions? = null optional**

`public void Save(Stream stream, ContentLineWriterOptions? options = null)` [#](#method-save-io-stream-officeimo-email-contentlinewriteroptions)

[IcsDocument.cs:98](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Email/Calendar/IcsDocument.cs#L98)

Saves this document to a caller-owned stream without closing it.

Parameters

**stream System.IO.Stream required**

**options OfficeIMO.Email.ContentLineWriterOptions? = null optional**

SaveAsync 2 overloads

`public Task SaveAsync(string filePath, ContentLineWriterOptions? options = null, CancellationToken cancellationToken = default)` [#](#method-saveasync-string-officeimo-email-contentlinewriteroptions-threading-cancellationtoken)

[IcsDocument.cs:103](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Email/Calendar/IcsDocument.cs#L103)

Asynchronously atomically saves this document to a file.

Parameters

**filePath string required**

**options OfficeIMO.Email.ContentLineWriterOptions? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`Task`

`public Task SaveAsync(Stream stream, ContentLineWriterOptions? options = null, CancellationToken cancellationToken = default)` [#](#method-saveasync-io-stream-officeimo-email-contentlinewriteroptions-threading-cancellationtoken)

[IcsDocument.cs:108](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Email/Calendar/IcsDocument.cs#L108)

Asynchronously saves to a caller-owned stream without closing it.

Parameters

**stream System.IO.Stream required**

**options OfficeIMO.Email.ContentLineWriterOptions? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`Task`

`public string Serialize(ContentLineWriterOptions? options = null)` [#](#method-serialize-officeimo-email-contentlinewriteroptions)

[IcsDocument.cs:88](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Email/Calendar/IcsDocument.cs#L88)

Serializes this document to text using the configured output encoding.

Parameters

**options OfficeIMO.Email.ContentLineWriterOptions? = null optional**

Returns

`string`

`public byte[] ToBytes(ContentLineWriterOptions? options = null)` [#](#method-tobytes-officeimo-email-contentlinewriteroptions)

[IcsDocument.cs:79](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Email/Calendar/IcsDocument.cs#L79)

Serializes this document to bytes.

Parameters

**options OfficeIMO.Email.ContentLineWriterOptions? = null optional**

Returns

`byte[]`

`public IReadOnlyList<ContentLineValidationIssue> Validate()` [#](#method-validate)

[IcsDocument.Validation.cs:13](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Email/Calendar/IcsDocument.Validation.cs#L13)

Validates stable RFC 5545 structure without rejecting unknown or extension properties.

Returns

`IReadOnlyList<ContentLineValidationIssue>`

## Inherited Methods

`public virtual bool Equals(object? obj)` [#](#method-equals-object)

Inherited from object

Parameters

**obj object? required**

Returns

`bool`

`public virtual int GetHashCode()` [#](#method-gethashcode)

Inherited from object

Returns

`int`

`public Type GetType()` [#](#method-gettype)

Inherited from object

Returns

`Type`

`public virtual string? ToString()` [#](#method-tostring)

Inherited from object

Returns

`string?`

## Properties

`public IList<ContentLineComponent> Calendars { get; }` [#](#property-calendars)

[IcsDocument.cs:20](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Email/Calendar/IcsDocument.cs#L20)

Ordered VCALENDAR roots. Unknown properties and nested components are retained.

<!-- PowerForge markdown artifact sha256:BFA1EB88599DBBF3AAA7B6DE1B6771858A9264E4147CB1E75AFBF5655299E597 -->
