Search code examples
.netemailoutlookicalendar

Icalender issue with outlook


I have generate calendar invitation from c# (.ics file). Also I have validate that using icalendar validator.

But when I send that file from outlook to another outlook mail its not display as invitation. Also its working fine with gmail to outlook and outlook to gmail

/ Create a calendar invitation
            string icsContent =
                "BEGIN:VCALENDAR\r\n" +
                "PRODID:-//Microsoft Corporation//Outlook 16.0 MIMEDIR//EN\r\n" +
                "VERSION:2.0\r\n" +
                "METHOD:REQUEST\r\n" +
                "BEGIN:VEVENT\r\n" +
                "DTSTART:20230302T160000Z\r\n" +
                "DTEND:20230302T170000Z\r\n" +
                "LOCATION:Conference Room\r\n" +
                "UID:" + Guid.NewGuid().ToString() + "\r\n" +
                "DESCRIPTION:Please join us for a meeting.\r\n" +
                "SUMMARY:Meeting Invitation\r\n" +
                "ORGANIZER;CN=Sender Name:MAILTO:[email protected]\r\n" +
                "ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Recipient Name:MAILTO:[email protected]\r\n" +
                "END:VEVENT\r\n" +
                "END:VCALENDAR\r\n";

            // Add the calendar invitation as an attachment
            Attachment icsAttachment = new Attachment(new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(icsContent)), "invitation.ics", "text/calendar");
            message.Attachments.Add(icsAttachment);

But when I send that file from outlook to another outlook mail its not display as invitation. Also its working fine with gmail to outlook and outlook to gmail


Solution

  • Add new ContentType("text/calendar; method=REQUEST") to calendar item