Michel
Michel

Reputation: 9440

HTML in iCal using iCal4j

Is there a possibility to add html to a description from a vevent.

I generate a VCALENDAR with a VEVENT with a description. I use Ical4j to sent the email with ICS

This is what I try to do:

BEGIN:VCALENDAR
PRODID:-//----//Calendar 1.0//ES
VERSION:2.0
METHOD:REQUEST
CALSCALE:GREGORIAN
BEGIN:VEVENT
DTSTAMP:20101202T145512Z
UID:20101202T145513Z-project@myPc
DESCRIPTION:ALTREP="CID:content-id-here":BlaBla
LOCATION:Room 2
SUMMARY:Confirmation
DTSTART:20110115T180000
DTEND:20110115T184500
ATTENDEE;ROLE=REQ-PARTICIPANT:mailto:[email protected]
ORGANIZER;SENT-BY=EyeContact:mailto:[email protected]
END:VEVENT
END:VCALENDAR

Content-Type:text/html
Content-Id:content-id-here

   <html>
     <head>
      <title></title>
     </head>
     <body>
       <p>
         <b>Example</b>
       </p>
     </body>
   </html>

Now it simply show the HTML code.

The above calendar I put in a MultiPart

message.addHeaderLine("method=REQUEST");
message.addHeaderLine("charset=UTF-8");
message.addHeaderLine("component=vevent");
message.setFrom(new InternetAddress(fromAddress));
message.addRecipient(Message.RecipientType.TO, new InternetAddress(app.getPanelist().getEmail()));
message.setSubject(subject);
Multipart mp = new MimeMultipart();
MimeBodyPart iCalAttachment = new MimeBodyPart();
iCalAttachment.setDataHandler(new DataHandler(new ByteArrayDataSource(new ByteArrayInputStream(invite), "text/calendar;method=REQUEST;charset=\"UTF-8\"")));
mp.addBodyPart(iCalAttachment);
message.setContent(mp);

Do I miss a part or is impossible?

EDIT - What I try to do with iCal4j (using Altrep)

ParameterList params = new ParameterList();     
URI uri = new URI("CID:content-id-here");
params.add(new AltRep(uri));
vEvent.getProperties().add(new Description(params,_content));

But with the code from above I'am stuck. Somebody a idea to use HTML in combination with iCall4j

Upvotes: 3

Views: 5340

Answers (2)

Michel
Michel

Reputation: 9440

I found the solution in this blogspot:

http://valermicle.blogspot.com/2009/02/i-was-searching-for-documentations-on.html

Using a MultiPart on the correct manner solved the problem

Upvotes: 3

mcrumley
mcrumley

Reputation: 5700

Looking at the iCalendar specifications, it looks like you need an "Alternate Text Representation" See RFC 5545 Section 3.2.1

Example:

   DESCRIPTION;ALTREP="CID:[email protected]":
    Project XYZ Review Meeting will include the following agenda
     items: (a) Market Overview\, (b) Finances\, (c) Project Man
    agement

The "ALTREP" property parameter value might point to a "text/html" content portion.

   Content-Type:text/html
   Content-Id:<[email protected]>

   <html>
     <head>
      <title></title>
     </head>
     <body>
       <p>
         <b>Project XYZ Review Meeting</b> will include
         the following agenda items:
         <ol>
           <li>Market Overview</li>
           <li>Finances</li>
           <li>Project Management</li>
         </ol>
       </p>
     </body>
   </html>

Upvotes: 2

Related Questions