我在莲花笔记中发送会议邀请时遇到了一些问题。我正试图看到接受/拒绝功能格式,但它只是作为添加到日历功能而出现。所以如果有人可以帮我这个会很棒。我的代码是
Properties props = new Properties();
props.put("mail.smtp.host", SMTP_HOST_NAME);
props.put("mail.smtp.auth", "false");
Authenticator auth = new SMTPAuthenticator();
Session session = Session.getInstance(props, auth);
session.setDebug(debug);
MimeMessage msg = new MimeMessage(session);
msg.addHeaderLine("method=REQUEST");
msg.addHeaderLine("charset=UTF-8");
msg.addHeaderLine("component=VEVENT");
InternetAddress addressFrom = new InternetAddress(from);
msg.setFrom(addressFrom);
if (!(recipients == null)) {
InternetAddress[] addressTo = new InternetAddress[recipients.length];
for (int i = 0; i < recipients.length; i++) {
addressTo[i] = new InternetAddress(recipients[i]);
}
log.debug("setting to recipients");
msg.setRecipients(Message.RecipientType.TO, addressTo);
}
if (!(recipientCC == null)) {
InternetAddress[] addressCC = new InternetAddress[recipientCC.length];
for (int j = 0; j < recipientCC.length; j++) {
addressCC[j] = new InternetAddress(recipientCC[j]);
}
log.debug("setting cc recipients");
msg.setRecipients(Message.RecipientType.CC, addressCC);
}
msg.setSubject(subject);
StringBuffer sb = new StringBuffer();
StringBuffer buffer = sb
.append("BEGIN:VCALENDAR\n"
+ "X-LOTUS-CHARSET:UTF-8\n"
+ "PRODID:-//Lotus Development Corporation//NONSGML Notes 8.5//EN_C\n"
+ "VERSION:2.0\n"
+ "BEGIN:VEVENT\n"
+ "CATEGORIES:Meeting\n"
+ "STATUS:NEEDS ACTION\n"
+ "DTSTART:20130727T184555\n"
+ "DTEND:20130727T194555\n"
+ "DTSTAMP:20130727T184555\n"
+ "SEQUENCE:0\n"
+ "EXPECT:IMMEDIATE\n"
+ "DESCRIPTION:Steve and John to review newest proposal material\n"
+ "SUMMARY:"
+ subject
+ "\n"
+ "CLASS:PUBLIC\n"
+ "UID:86DC83601F9625C465257BB40047FE17-Lotus_Notes_Generated\n"
+ "X-LOTUS-UPDATE-SEQ:1\n"
+ "X-LOTUS-UPDATE-WISL:$S:1;$L:1;$B:1;$R:1;$E:1;$W:1;$O:1;$M:1\n"
+ "X-LOTUS-NOTESVERSION:2\n"
+ "X-LOTUS-NOTICETYPE:I\n"
+ "X-LOTUS-APPTTYPE:3\n"
+ "X-LOTUS-CHILD-UID:86DC83601F9625C465257BB40047FE17\n"
+ "END:VEVENT\n" + "END:VCALENDAR\n");
// Create the message part
BodyPart messageBodyPart = new MimeBodyPart();
// Fill the message
messageBodyPart.setHeader("Content-Class",
"urn:content-classes:calendarmessage");
messageBodyPart.setHeader("Content-ID", "calendar_message");
messageBodyPart
.setDataHandler(new DataHandler(new ByteArrayDataSource(
buffer.toString(), "text/calendar")));// very
// important
// Create a Multipart
Multipart multipart = new MimeMultipart();
// Add part one
multipart.addBodyPart(messageBodyPart);
// Put parts in message
msg.setContent(multipart);
log.debug("Sending mail");
Transport.send(msg);
答案 0 :(得分:2)
如果您希望能够回复,则需要创建群组活动而不是公共活动。您可以阅读有关此in the RFC 2446的所有内容。
必须为群组活动定义与会者才能工作(请参阅上述文档中的第4.2章)。这可能如下所示:
ATTENDEE;ROLE=CHAIR;PARTSTAT=ACCEPTED;CN=BIG A:Mailto:A@example.com
ATTENDEE;RSVP=TRUE;TYPE=INDIVIDUAL;CN=B:Mailto:B@example.com
RSVP = TRUE让B回复。
如果您需要确保,这些约会不会混淆,请为每个事件生成一个唯一的uid,并在发生更改时重复使用它。否则您将无法发送更新。