---
title: "Render an ICS invite as an HTML card in C#"
url: https://recursiveai.org/onemail/cookbook/render-calendar-invitation-card/
description: "Render an ICS meeting invite as a standalone HTML card in C#. Show the time, location, organizer and attendees without rendering the email or sending an invitation."
version: "1.0.1"
---

# Render an ICS invite as an HTML card in C#

**OneMail** is a free, open-source email library for .NET from Recursive AI. MIT or Apache-2.0, no native dependencies.

[NuGet](https://www.nuget.org/packages/RecursiveAI.OneMail) · [GitHub](https://github.com/recursive-ai-oss/onemail-csharp) · [Docs](https://recursiveai.org/onemail/docs/) · [Download example (.zip)](https://recursiveai.org/onemail/cookbook/render-calendar-invitation-card/render-calendar-invitation-card.zip)

`invite.ics` is in the download. The card doesn’t include the surrounding email.

```shell
dotnet add package RecursiveAI.OneMail
```

Requires [.NET 10](https://dotnet.microsoft.com/download/dotnet/10.0) (net10.0); .NET 9 and earlier aren’t supported.

```csharp
using RecursiveAI.OneMail.Display;

var bytes = File.ReadAllBytes("invite.ics");
var card = CalendarCard.FromIcs(bytes).First();
File.WriteAllText("invite.html", card.ToHtml());
Console.WriteLine(card.ToText());
```

Unzip [the example](https://recursiveai.org/onemail/cookbook/render-calendar-invitation-card/render-calendar-invitation-card.zip), then `dotnet run`.

The snippet saves `invite.html` and prints the card’s plain-text version:

```text
Invitation
Studio review
When: Tue, 1 Dec 2026 14:00–14:30 (UTC)
Where: Room 2
Organizer: Alex (alex@example.test)
Attendees:
  Sam (sam@example.test)
```

Here are the invitation label and title from the HTML that `ToHtml()` wrote to `invite.html`:

```html
<p class="onemail-card-action" style="margin:0 0 2px;color:#555">Invitation</p>
<p class="onemail-card-title" style="margin:0 0 4px;font-size:16px"><strong>Studio review</strong></p>
```

## The full program

```text
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Example//Studio calendar//EN
METHOD:REQUEST
BEGIN:VEVENT
UID:review@example.test
DTSTAMP:20261130T120000Z
DTSTART:20261201T140000Z
DTEND:20261201T143000Z
SUMMARY:Studio review
LOCATION:Room 2
ORGANIZER;CN=Alex:mailto:alex@example.test
ATTENDEE;CN=Sam:mailto:sam@example.test
END:VEVENT
END:VCALENDAR
```

```csharp
using RecursiveAI.OneMail.Display;

var bytes = File.ReadAllBytes("invite.ics");
var card = CalendarCard.FromIcs(bytes).First();
File.WriteAllText("invite.html", card.ToHtml());
Console.WriteLine(card.ToText());
Console.WriteLine("Wrote invite.html");
```

`dotnet run` prints:

```text
Invitation
Studio review
When: Tue, 1 Dec 2026 14:00–14:30 (UTC)
Where: Room 2
Organizer: Alex (alex@example.test)
Attendees:
  Sam (sam@example.test)

Wrote invite.html
```

Open `invite.html` in a browser to see the card. The saved HTML is a fragment, not a page with a title or navigation.

If the file contains no supported calendar item, `FromIcs` returns no cards; check the list before calling `First()` on files you didn’t create.

## Variations

**Show the meeting in the reader’s time zone.** Replace the lines after the file read with these:

```csharp
var options = new CalendarCardOptions
{
    DisplayTimeZone = "Europe/Paris"
};
var card = CalendarCard.FromIcs(bytes, options).First();
Console.WriteLine(card.When);
```

```text
Tue, 1 Dec 2026 15:00–15:30 (Europe/Paris, UTC+01:00)
```

## Related recipes

- [Read an ICS calendar file in C#](https://recursiveai.org/onemail/cookbook/read-ics-file/)
- [Render an email as HTML in C#](https://recursiveai.org/onemail/cookbook/render-email-as-html/)

## The short answer

Read the `.ics` file as bytes, call `CalendarCard.FromIcs`, and call `ToHtml()` on the returned card you want to display. This handles the view of the invitation, not the invitation itself: it doesn’t send email, update a calendar or record an RSVP. Keep the original `.ics` when the recipient needs those calendar details for another app.

## How can I preview an ICS file in a browser?

Save the fragment as `.html` to view it on its own, or place it where the invitation belongs in the page your app renders. The card labels this sample “Invitation” because the calendar has `METHOD:REQUEST`. A later request with a higher sequence can show “Updated invitation,” and `METHOD:CANCEL` shows “Cancelled.” A calendar export without a method displays “Event.”

`FromIcs` returns a list because a file can contain multiple series. The snippet takes the first because the sample has one. If a calendar has independent events, choose the appropriate card or render each one. A changed instance with the same UID as the master event belongs to that series rather than getting a separate card. Recurring cards show a rule description when it can be expressed accurately, plus a bounded list of occurrences. The card starts that list at the series start unless you supply an `After` cutoff.

## Can an ICS meeting preview show the original organizer time?

Yes. If you pass a display zone and the times differ, the card shows the converted time and keeps the organizer’s time alongside it. In this example the input explicitly says 14:00 UTC; in Paris on that date it’s 15:00. A floating time has no zone to convert from, so it is shown as written. An unrecognized display zone falls back to the event zone and adds a diagnostic. The [calendar card fields](https://recursiveai.org/onemail/docs/calendar-card/) describe which fields get shortened, including long descriptions and attendee lists. Use the original calendar file rather than the preview when you need the complete record.
