java - iCal 中的 HTML 使用 iCal4j

标签 java outlook outlook-2007 icalendar vcalendar

是否有可能将 html 添加到 vevent 的描述中。

我生成一个 VCALENDAR 和一个带有描述的 VEVENT。我用 Ical4j使用 ICS

发送电子邮件

这是我尝试做的:

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>

现在它只显示 HTML 代码。

上面的日历我放在一个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);

我错过了一部分还是不可能?

编辑 - 我尝试用 iCal4j 做什么(使用 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));

但是上面的代码让我卡住了。有人提出将 HTML 与 iCall4j 结合使用的想法

最佳答案

我在这个博客中找到了解决方案:

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

以正确的方式使用 MultiPart 解决了问题

关于java - iCal 中的 HTML 使用 iCal4j,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4336432/

相关文章:

java - 正确填充图像中的孔

java - 正则表达式捕获组并忽略最后两个字符(其中一个是可选的)

java - 当按下 Enter 键时使用 Utilities.getRowStart 时出现 BadLocationException

HTML:无法对齐图像和文本

c# - C#/.NET (VS 2008) 到 Outlook (2007) 的问题

JAVA - 实例化 Scala 案例类

c# - 嵌入式 Outlook View 控件

calendar - 发布 Outlook 日历。服务器端同步频率的设置是什么?

c# - 在 Outlook 中捕获 BeforeItemCopy 事件

c# - 用于将自定义字段添加到邮件表单或使用 C# 访问现有字段的 Outlook 插件