leonardo
leonardo

Reputation: 121

How generate an ics with hyper link on description using javascript

I'm trying to generate an .ics file using javascript. I am able to open the ics file but when I try to set an html in the body of the ics file the html is shown like plain text... Below is the parameter string I trying to use to set the description as html... Does anyone know what I'm doing wrong?

"BEGIN:VCALENDAR
 VERSION:2.0
 BEGIN:VEVENT
 CLASS:PUBLIC
 DESCRIPTION:
 X-ALT-DESC;FMTTYPE=text\/html:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META NAME="Generator" CONTENT="MS Exchange Server version 08.01.0240.003">
<TITLE></TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->

<P DIR=LTR><SPAN LANG="en-us"></SPAN></P>

 <A href="www.google.com" title="TEST">TEST</A></BODY>
</HTML>
DTSTART;VALUE=DATE:20160512T123232
DTEND;VALUE=DATE:20160512T123232
LOCATION:
SUMMARY;LANGUAGE=en-us:summary
TRANSP:TRANSPARENT
END:VEVENT
END:VCALENDAR"

Upvotes: 1

Views: 5461

Answers (3)

Ben Bucksch
Ben Bucksch

Reputation: 660

The iCal spec actually explicitly specifies a way to include HTML in iCal:

The definition of ALTREP says: "The parameter specifies a URI that points to an alternate representation for a textual property value", so any URI scheme is valid. That means we can also use data: URLs in there.

That means there is actually a specced way to store HTML descriptions in iCal.

The following is conforming to the spec:

DESCRIPTION;ALTREP="data:text/html;<h1>Some text</h1>":Some text

Upvotes: 3

Arnaud Quillaud
Arnaud Quillaud

Reputation: 4635

There are several issues with your example:

Bottom line:

  1. Try to use an existing iCalendar library to generate your content. This will take care of all the escaping for you
  2. Do generate some iCalendar sample events using rich text and whatever client you are targeting (Outlook ?) as that should give you a good starting point.

Upvotes: 0

wajiro_91
wajiro_91

Reputation: 170

If you read iCalendar Protocol, using the ALTREP property parameter you can accomplish so, even including html content. Now when the client take the calendar file, it process the content and take the data that it needs from the different calendar components and properties. So if the client use the ALTREP property parameter it might render the content in the html format. I don't know if Outlook render the content following the ALTREP param, maybe there is other client that do so. Maybe what you have to looking for is a client that render the content by its ALTREP.

Hope it helps

Upvotes: 0

Related Questions