Using X-ALT-DESC / Applying HTML to calendar invites in Outlook
You can have X-ALT-DESC on multiple lines, you just need to add a space on the beginning of each lines following it.
Lines of text SHOULD NOT be longer than 75 octets, excluding the line break. Long content lines SHOULD be split into a multiple line representations using a line "folding" technique. That is, a long line can be split between any two characters by inserting a CRLF immediately followed by a single linear white-space character (i.e., SPACE or HTAB). Any sequence of CRLF followed immediately by a single linear white-space character is ignored (i.e., removed) when processing the content type.
https://icalendar.org/iCalendar-RFC-5545/3-1-content-lines.html
How do I create an HTML-formatted ICS message body using ical.net?
HTML formatting isn't part of the icalendar spec, so it's up to applications to add support for this via the non-standard property fields, which are designated with an X-
prefix. (Further reading on non-standard properties if you're interested.)
Google calendar
It doesn't look like Google calendar has any support for HTML-formatted events, so I think you're out of luck there.
Outlook
Outlook uses a number of these X-
fields for various things; for HTML-formatted descriptions, it uses X-ALT-DESC
and specifies FMTTYPE=text/html
like this:
X-ALT-DESC;FMTTYPE=text/html:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//E
N">\n<HTML>\n<HEAD>\n<META NAME="Generator" CONTENT="MS Exchange Server ve
rsion rmj.rmm.rup.rpr">\n<TITLE></TITLE>\n</HEAD>\n<BODY>\n<!-- Converted
from text/rtf format -->\n\n<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Cali
bri">This is some</FONT></SPAN><SPAN LANG="en-us"><B> <FONT FACE="Calibri"
>HTML</FONT></B></SPAN><SPAN LANG="en-us"><FONT FACE="Calibri"></FONT></SP
AN><SPAN LANG="en-us"><U> <FONT FACE="Calibri">formatted</FONT></U></SPAN>
<SPAN LANG="en-us"><FONT FACE="Calibri"></FONT></SPAN><SPAN LANG="en-us"><
I> <FONT FACE="Calibri">text</FONT></I></SPAN><SPAN LANG="en-us"><FONT FAC
E="Calibri">.</FONT></SPAN><SPAN LANG="en-us"></SPAN></P>\n\n</BODY>\n</HT
ML>
You may be able to get away with much simpler HTML, you'll have to test to see what Outlook supports/allows. The HTML block above was generated using Outlook 2013. I have successfully used that block and run it through a serialization round-trip with ical.net, and Outlook opens it without any fuss.
ical.net
Unfortunately you can't quite do this in ical.net due a bug with CalendarProperty
serialization, but the workaround is just one line.
const string formatted = //the text block from above starting with FMTTYPE=text/html:
var start = DateTime.Now;
var end = start.AddHours(1);
var @event = new Event
{
Start = new CalDateTime(start),
End = new CalDateTime(end),
Description = "This is a description",
};
var property = new CalendarProperty("X-ALT-DESC", formatted);
@event.AddProperty(property);
var calendar = new Calendar();
calendar.Events.Add(@event);
var serialized = new CalendarSerializer().SerializeToString(calendar);
//Workaround for the bug:
serialized = serialized.Replace("X-ALT-DESC:FMTTYPE=text/html", "X-ALT-DESC;FMTTYPE=text/html");
This will produce HTML-formatted Outlook calendar events.
(When I fix the bug, I'll update this answer to remove the string.Replace
call.)
Add HTML in ICS file for Outlook Appointment
I finally managed to resolved this.
Please find below the solution:-
private static byte[] CreateiCal(int current_sequence, string guid, string subject, string location, DateTime startTime, DateTime endTime)
{
var a = new StringBuilder();
int sequence = current_sequence + 1;
a.Append("BEGIN:VCALENDAR\r\f");
a.Append("VERSION:2.0\r\f");
a.Append("PRODID:-//ince/events//NONSGML v1.0//EN\r\f");
a.Append("TZ:+00\r\f");
a.Append("BEGIN:VEVENT\r\f");
a.Append(String.Format("SEQUENCE:{0}\r\f", sequence.ToString()));
a.Append(String.Format("DTSTART:{0}\r\f", GetFormatedDate(startTime)));
a.Append(String.Format("DTEND:{0}\r\f", GetFormatedDate(endTime)));
a.Append(String.Format("LOCATION:{0}\r\f", location));
a.Append(String.Format("UID:{0}\r\f", guid));
a.Append(String.Format("SUMMARY:{0}\r\f", subject));
string desc = File.ReadAllText("Sample.html", Encoding.GetEncoding("iso-8859-1")); // iso-8859-1 : HTML contains French characters
a.Append("X-ALT-DESC;FMTTYPE=text/html:" + desc + "\r\f");
a.Append(String.Format("DESCRIPTION:{0}\r\f", desc));
a.Append(String.Format("X-MICROSOFT-CDO-APPT-SEQUENCE:{0}\r\f", current_sequence.ToString()));
a.Append("BEGIN:VALARM\r\f");
a.Append("TRIGGER:-PT15M\r\f");
a.Append("REPEAT:2\r\f");
a.Append("DURATION:PT15M\r\f");
a.Append("ACTION:DISPLAY\r\f");
a.Append("DESCRIPTION:Reminder\r\f");
a.Append("END:VALARM\r\f");
a.Append("END:VEVENT\r\f");
a.Append("END:VCALENDAR\r\f");
byte[] b = Encoding.UTF8.GetBytes(a.ToString());
return b;
}
NOTE:- I've to minify the HTML before Saving it in the "Sample.html" file.
Hope it helps others!!
Outlook 2013 invite not showing embeded attachment - text/calendar;method=REQUEST
Outlook expects the meeting request MIME message to be a single part - text/calendar. Plain text and HTML must be in the VEVENT part (DESCRIPTION and X-ALT-DESC respectively). Attachments must also be added as ATTACH parts:
MIME-Version: 1.0
Subject: Test
Content-ID: <30261.1428705114.6@cleaf1.mydomain.org>
Content-Type: text/calendar
BEGIN:VCALENDAR
PRODID:-//Microsoft Corporation//Outlook 14.0 MIMEDIR//EN
VERSION:2.0
METHOD:PUBLISH
BEGIN:VEVENT
ATTACH;ENCODING=BASE64;VALUE=BINARY;X-FILENAME=test.txt:U3ViamVjdDoJRG1pdHJ
5IE9uZSBvbiBPbmUNCkxvY2F0aW9uOglQYXVsJ3MgT2ZmaWNlDQoNClN0YXJ0OglUdWUgMTIvN
C8yMDEyIDk6MzAgQU0NCkVuZDoJVHVlIDEyLzQvMjAxMiA5OjQ1IEFNDQoNClJlY3VycmVuY2U
6CVdlZWtseQ0KUmVjdXJyZW5jZSBQYXR0ZXJuOglPY2N1cnMgZXZlcnkgVHVlc2RheSBmcm9tI
Dk6MzAgQU0gdG8gOTo0NSBBTSBlZmZlY3RpdmUgMS8xNy8yMDEyLiAoVVRDLQ0KMDc6MDApIEF
yaXpvbmENCg0KTWVldGluZyBTdGF0dXM6CUFjY2VwdGVkDQoNCk9yZ2FuaXplcjoJWmVpbWV0L
CBQYXVsDQpSZXF1aXJlZCBBdHRlbmRlZXM6CVN0cmVibGVjaGVua28sIERtaXRyeQ0KDQoNCg=
=
DESCRIPTION:Test appointment body\n\n \n
X-ALT-DESC;FMTTYPE=text/html:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//E
N">\n<HTML>\n<HEAD>\n<META NAME="Generator" CONTENT="MS Exchange Server ve
rsion 14.02.5004.000">\n<TITLE></TITLE>\n</HEAD>\n<BODY>\n<!-- Converted f
rom text/rtf format -->\n\n<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Calib
ri">Test</FONT></SPAN><SPAN LANG="en-us"><B> <FONT FACE="Calibri">appointm
ent</FONT></B></SPAN><SPAN LANG="en-us"><FONT FACE="Calibri"> body</FONT><
/SPAN><SPAN LANG="en-us"></SPAN></P>\n\n<P DIR=LTR><SPAN LANG="en-us"></SP
AN><SPAN LANG="en-us"> \;</SPAN></P>\n\n</BODY>\n</HTML>
END:VEVENT
END:VCALENDAR
Update. Outlook created the following MIME message when I sent a meeting invitation from Outlook (I removed some headers for clarity).
Return-Path: <xx@yy.com>
X-Original-To: xx@yy.com
Delivered-To: xx@yy.com
From: Dmitry Streblechenko < xx@yy.com>
To: "xx@yy.com" <xx@yy.com>
Subject: test with attachment
Thread-Topic: test with attachment
Thread-Index: AdB1Rk+XNqVZqNnURi+hrlBAI6rRFwAACvNA
Date: Sun, 12 Apr 2015 17:31:20 +0000
Message-ID: <CY1PR11MB05242BD9613D40DB120FCCA8B7F80@CY1PR11MB0524.namprd11.prod.outlook.com>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach: yes
X-MS-TNEF-Correlator:
MIME-Version: 1.0
--_005_CY1PR11MB05242BD9613D40DB120FCCA8B7F80CY1PR11MB0524namp_
Content-Type: multipart/alternative;
boundary="_000_CY1PR11MB05242BD9613D40DB120FCCA8B7F80CY1PR11MB0524namp_"
--_000_CY1PR11MB05242BD9613D40DB120FCCA8B7F80CY1PR11MB0524namp_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Test body
--_000_CY1PR11MB05242BD9613D40DB120FCCA8B7F80CY1PR11MB0524namp_
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<html>
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Diso-8859-=
1">
<meta name=3D"Generator" content=3D"Microsoft Exchange Server">
<!-- converted from rtf -->
<style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left:=
#800000 2px solid; } --></style>
</head>
<body>
<font face=3D"Calibri" size=3D"2"><span style=3D"font-size:11pt;">
<div>Test <b>body</b></div>
<div><font face=3D"Times New Roman"> </font></div>
<div><font face=3D"Times New Roman"> </font></div>
<div><font face=3D"Times New Roman"> </font></div>
</span></font>
</body>
</html>
--_000_CY1PR11MB05242BD9613D40DB120FCCA8B7F80CY1PR11MB0524namp_
Content-Type: text/calendar; charset="utf-8"; method=REQUEST
Content-Transfer-Encoding: base64
QkVHSU46VkNBTEVOREFSDQpNRVRIT0Q6UkVRVUVTVA0KUFJPRElEOk1pY3Jvc29mdCBFeGNoYW5n
ZSBTZXJ2ZXIgMjAxMA0KVkVSU0lPTjoyLjANCkJFR0lOOlZUSU1FWk9ORQ0KVFpJRDpVUyBNb3Vu
dGFpbiBTdGFuZGFyZCBUaW1lDQpCRUdJTjpTVEFOREFSRA0KRFRTVEFSVDoxNjAxMDEwMVQwMDAw
MDANClRaT0ZGU0VURlJPTTotMDcwMA0KVFpPRkZTRVRUTzotMDcwMA0KRU5EOlNUQU5EQVJEDQpC
RUdJTjpEQVlMSUdIVA0KRFRTVEFSVDoxNjAxMDEwMVQwMDAwMDANClRaT0ZGU0VURlJPTTotMDcw
MA0KVFpPRkZTRVRUTzotMDcwMA0KRU5EOkRBWUxJR0hUDQpFTkQ6VlRJTUVaT05FDQpCRUdJTjpW
RVZFTlQNCk9SR0FOSVpFUjtDTj1EbWl0cnkgU3RyZWJsZWNoZW5rbzpNQUlMVE86ZG1pdHJ5QGRp
Z2l0YWwudGVjaG5vbG9neQ0KQVRURU5ERUU7Uk9MRT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UFQUFQtU0VRVUVOQ0U6MA0KWC1NSUNST1NPRlQtQ0RPLU9XTkVSQVBQVElEOi02MjIwNDkz
MTMNClgtTUlDUk9TT0ZULUNETy1CVVNZU1RBVFVTOlRFTlRBVElWRQ0KWC1NSUNST1NPRlQtQ0RP
LUlOVEVOREVEU1RBVFVTOkJVU1kNClgtTUlDUk9TT0ZULUNETy1BTExEQVlFVkVOVDpGQUxTRQ0K
WC1NSUNST1NPRlQtQ0RPLUlNUE9SVEFOQ0U6MQ0KWC1NSUNST1NPRlQtQ0RPLUlOU1RUWVBFOjAN
ClgtTUlDUk9TT0ZULURJU0FMTE9XLUNPVU5URVI6RkFMU0UNCkJFR0lOOlZBTEFSTQ0KREVTQ1JJ
UFRJT046UkVNSU5ERVINClRSSUdHRVI7UkVMQVRFRD1TVEFSVDotUFQxNU0NCkFDVElPTjpESVNQ
TEFZDQpFTkQ6VkFMQVJNDQpFTkQ6VkVWRU5UDQpFTkQ6VkNBTEVOREFSDQo=
--_000_CY1PR11MB05242BD9613D40DB120FCCA8B7F80CY1PR11MB0524namp_--
--_005_CY1PR11MB05242BD9613D40DB120FCCA8B7F80CY1PR11MB0524namp_
Content-Type: application/octet-stream; name="manifest.rc"
Content-Description: manifest.rc
Content-Disposition: attachment; filename="manifest.rc"; size=27;
creation-date="Sat, 24 Apr 2010 05:10:59 GMT";
modification-date="Tue, 30 Dec 2014 00:22:47 GMT"
Content-ID: <8BC00E3E496DC4499002ED7488F8E084@namprd11.prod.outlook.com>
Content-Transfer-Encoding: base64
MSAyNCBDdXN0b21pemUuZXhlLm1hbmlmZXN0
--_005_CY1PR11MB05242BD9613D40DB120FCCA8B7F80CY1PR11MB0524namp_--
Send email as calendar invite/appointment in SendGrid C#
Related Topics
Could Not Start Windows Service, Error 1064
Posting Jsonobject With Httpclient from Web API
How to Use Telegram API in C# to Send a Message
Data Binding in MVC 5 and Select2 Multiple Values With Razor Engine
Encode a Filestream to Base64 With C#
How to Read Appsettings.Json With Array of Values
How to Remove Carriage Returns from the Json Output of My Webapi Service
Pass Array into ASP.NET Core Route Query String
Error: the Entity Type Requires a Primary Key
C# Download Big File from Server With Less Memory Consumption
Multidimensional Array from a Txt File
Use Latest Version of Internet Explorer in the Webbrowser Control
How to Convert English Digits to Arabic Digits
Check If Combobox Value Is Empty
Moq - Non-Overridable Members May Not Be Used in Setup/Verification Expressions
Why Am I Getting Error Cs0246: the Type or Namespace Name Could Not Be Found