dotnet add package DevOp.ICalendar
The package targets net10.0, net8.0 and netstandard2.0. It depends on MimeKit (for the iMIP composer) and
on Microsoft.Extensions.DependencyInjection.Abstractions and Microsoft.Extensions.Options (for the optional
service registration); on netstandard2.0 it also depends on System.Text.Json.
using DevOp.ICalendar;
var meeting = new IcalComponent
{
Uid = "[email protected]",
Start = new DateTimeOffset(2026, 11, 20, 14, 0, 0, TimeSpan.Zero),
End = new DateTimeOffset(2026, 11, 20, 15, 0, 0, TimeSpan.Zero),
Summary = "Quarterly review",
Description = "Agenda: results, plans.",
DescriptionDerived = true,
Organizer = "[email protected]",
OrganizerName = "Anna Jónsdóttir",
Attendees = [new IcalAttendee { Address = "[email protected]", DisplayName = "Dana Lee", Rsvp = true }],
Conferences = [new IcalConference("https://meet.example.com/review") { Features = [IcalConferenceFeature.Video], Label = "Join the call" }],
Alarms = [new IcalAlarm { TriggerBeforeStart = TimeSpan.FromMinutes(15), Description = "Review in 15 minutes" }],
Properties = [IcalProperty.StyledDescriptionHtml("<p>Agenda: <b>results</b>, plans.</p>")],
};
Start and End are instants. Organizer and attendee Address are email addresses; the mailto: scheme is
added on the way out and removed on the way in.
string ics = IcalCodec.Serialize([meeting], ItipMethod.Request);
The result:
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//DevOp//DevOp.ICalendar//EN
CALSCALE:GREGORIAN
METHOD:REQUEST
BEGIN:VEVENT
UID:[email protected]
SEQUENCE:0
DTSTAMP:20261120T140000Z
DTSTART:20261120T140000Z
DTEND:20261120T150000Z
SUMMARY:Quarterly review
DESCRIPTION;DERIVED=TRUE:Agenda: results\, plans.
ORGANIZER;CN=Anna Jónsdóttir:mailto:[email protected]
TRANSP:OPAQUE
X-MICROSOFT-CDO-BUSYSTATUS:BUSY
ATTENDEE;CN=Dana Lee;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE:m
ailto:[email protected]
CONFERENCE;VALUE=URI;FEATURE=VIDEO;LABEL=Join the call:https://meet.example
.com/review
STYLED-DESCRIPTION;VALUE=TEXT;FMTTYPE=text/html:<p>Agenda: <b>results</b>\,
plans.</p>
BEGIN:VALARM
ACTION:DISPLAY
DESCRIPTION:Review in 15 minutes
TRIGGER;RELATED=START:-PT15M
END:VALARM
END:VEVENT
END:VCALENDAR
Lines end in CRLF and are folded at 75 octets. DTSTAMP falls back to Start because the event names none; set
DtStamp to stamp the message yourself. Nothing in the library reads a clock, so the same input always gives the
same bytes. Pass your own PRODID as the third argument, or set IcalDocument.ProdId.
IcalDocument parsed = IcalCodec.Parse(ics, IcalParseLimits.Default);
IcalComponent back = parsed.Components[0];
// parsed.Method == ItipMethod.Request
// back.Attendees[0].Rsvp == true
// back.Alarms[0].TriggerBeforeStart == TimeSpan.FromMinutes(15)
// back.UnknownProperties contains the STYLED-DESCRIPTION line, verbatim
Use the overload with IcalParseLimits for anything you did not write yourself; IcalCodec.Parse(ics) has no
size bound. Typed extra properties (Properties) are write-only: on the way in they arrive in
UnknownProperties, and are written back unchanged.
The model is immutable; use with:
var moved = back with
{
Sequence = back.Sequence + 1,
Start = back.Start!.Value.AddHours(1),
End = back.End!.Value.AddHours(1),
};
string update = IcalCodec.Serialize([moved], ItipMethod.Request);
You own SEQUENCE: increase it when the change matters to attendees (RFC 5546 §2.1.4).
var weekly = meeting with
{
TimeZone = "Europe/Berlin",
Recurrence = new IcalRecurrenceRule { Frequency = IcalFrequency.Weekly, Count = 10, ByDay = [DayOfWeek.Thursday] },
};
A recurring component whose zone changes its offset is written as DTSTART;TZID=Europe/Berlin:… with a generated
VTIMEZONE, so it repeats at the same wall-clock time across a daylight-saving change.