0

我在 Lotus Notes 中发送会议邀请时遇到了一些问题。我正在尝试以接受/拒绝功能格式查看,但它只是作为添加到日历功能中出现。所以如果有人可以帮助我解决这个问题,那就太好了.这是我的代码

        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);
4

1 回答 1

2

如果您希望能够响应,您需要创建一个群组事件而不是公共事件。您可以在 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,并在发生变化时重用它。否则您将无法发送更新。

于 2013-08-01T05:31:13.740 回答