iTIP (RFC 5546) defines the scheduling messages; iMIP (RFC 6047) carries them by email. DevOp.ICalendar writes and
reads the calendar objects and builds the MIME message. Scheduling policy (who may send what, when a change is
material, how a reply is applied) and sending stay with your application.
ItipMethod has the eight RFC 5546 methods. ItipMethods.Token gives the wire token and ItipMethods.Parse
reads one (case-insensitive; null for an unknown token).
| Method | Token | Sent by | Use |
|---|---|---|---|
Publish |
PUBLISH |
organizer | A calendar object with no reply expected, such as an exported booking. |
Request |
REQUEST |
organizer | An invitation, or an update to one. |
Reply |
REPLY |
attendee | Accept, decline or tentatively accept. |
Add |
ADD |
organizer | Add occurrences to a series. |
Cancel |
CANCEL |
organizer | Cancel an event or occurrences. |
Refresh |
REFRESH |
attendee | Ask for the latest version. |
Counter |
COUNTER |
attendee | Propose a change. |
DeclineCounter |
DECLINECOUNTER |
organizer | Reject a counter-proposal. |
IcalCodec.Serialize(components, method) writes METHOD: on the VCALENDAR; IcalCodec.ReadMethod(text) and
IcalDocument.Method read it back. A document without a method is a plain calendar object.
Every message about one event carries the same UID, and a change attendees must see carries a higher
SEQUENCE. Both are yours: the library writes them verbatim and never invents an identifier or bumps a sequence,
so exactly one system decides the version of an appointment.
A METHOD:REPLY cannot carry an alarm (RFC 5546 §3.2.3). IcalCodec.Serialize throws ArgumentException when a
component of a REPLY has an alarm in Alarms, including a display alarm a parse read into Alarms (Outlook's
reminder is one). Alarms kept verbatim from a parsed request (a VALARM in UnknownProperties or
OverrideComponents) are left out of a REPLY. So build the reply from the parsed request by clearing Alarms and
setting your attendee's ParticipationStatus:
var reply = request with
{
Alarms = [],
Attendees = [me with { ParticipationStatus = IcalParticipationStatus.Accepted }],
};
string ics = IcalCodec.Serialize([reply], ItipMethod.Reply);
ImipEnvelope is the one vocabulary for both directions.
ImipEnvelope.ForOutbound(ics, method) wraps a payload and its method in an ImipCalendarPart.ImipEnvelope.ContentTypeFor(method) is the MIME type: text/calendar; charset=utf-8; method=REQUEST.ImipEnvelope.ForInbound(mediaType, methodParameter, body) classifies one received MIME part: null when it istext/calendar; otherwise the method comes from the method= parameter, then the payload's METHOD, thenPUBLISH (the RFC 6047 default). Finding the part in a MIME tree is your MIME library's job.RFC 6047 §2.4 requires the method= parameter and the payload's METHOD to match; it is that pair that makes a
mail client treat the part as a scheduling message rather than a file.
var message = new ImipMessage
{
From = "Anna Jónsdóttir <[email protected]>",
To = ["[email protected]"],
Subject = "Quarterly review",
TextSummary = "You are invited to the quarterly review on 20 November at 14:00 UTC.",
Calendar = ImipEnvelope.ForOutbound(ics, ItipMethod.Request),
};
MimeKit.MimeMessage mime = ImipMessageComposer.Compose(message);
using MemoryStream bytes = ImipMessageComposer.ComposeToStream(message);
Compose builds a multipart/alternative with a text/plain part (TextSummary, or
ImipMessageComposer.DefaultTextSummary) and an inline text/calendar part (charset=utf-8, method=…, file name
invite.ics unless FileName says otherwise), and adds Content-Class: urn:content-classes:calendarmessage.
It throws ArgumentException when an address does not parse, the subject or an address contains a line break,
there is no recipient, the payload is blank, or the payload's METHOD is missing or differs from the declared one.
The mismatch is refused, not repaired.
ComposeToStream returns a rewound stream with CRLF line endings on every OS (MimeKit's default follows the OS).
If you DKIM-sign the message, pass the same FormatOptions your signer uses, because the signature covers the
bytes as serialized.
// contentType is the part's MimeKit.ContentType, body its decoded text.
contentType.Parameters.TryGetValue("method", out string? methodParameter);
ImipCalendarPart? part = ImipEnvelope.ForInbound(contentType.MimeType, methodParameter, body);
if (part is not null)
{
IcalDocument document = IcalCodec.Parse(part.Ics, IcalParseLimits.Default);
}
Parse inbound calendars with limits; see security.