简体   繁体   中英

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:foo@bar.com
ORGANIZER;SENT-BY=EyeContact:mailto:foo@bar.com
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

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

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:part3.msg.970415T083000@example.com": 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:<part3.msg.970415T083000@example.com> <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> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM