Recursive AI

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.

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

Terminal
dotnet add package RecursiveAI.OneMail

Requires .NET 10 (net10.0); .NET 9 and earlier aren’t supported.

C#
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, 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
C#
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:

C#
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)

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 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.

All onemail recipes