简体   繁体   中英

Meeting Invite on Lotus notes using Java API

I am getting some problem while sending meeting invite in lotus notes.i am trying to see in the accept/decline feature format but instead it is just coming up as add to Calendar Feature only.So if anyone can help me with this would be great.here is my code

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

You need to create a group event instead of a public event, if you want to be able to respond. You can read everything about this in the RFC 2446 .

It is mandatory to define attendees for a group event to work (see Chapter 4.2 in above documentation). This might look like this:

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 lets B respond.

If you need to make sure, that appointments do not get mixed up, generate a unique uid for every event and reuse it if something changes. Otherwise you will not be able to send updates.

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