Search code examples
javaoutlookoutlook-2007icalendarvcalendar

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


Solution

  • 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