接受日历邀请时将自动回复发送到组织者

时间:2019-06-21 09:17:33

标签: java icalendar

我正在发送带有ics文件的电子邮件。与会者接受日历后,邮件将自动发送到组织者作为确认。但是当与会者接受时,它将被添加到日历中,但邮件没有被发送到组织者。

这是我的icalFileContent,将在Java代码中使用

BEGIN:VCALENDAR
PRODID:-//xxxxx //Calendar Event//EN
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:REQUEST
BEGIN:VEVENT
UID:54131
DTSTAMP:xxxxx
DTSTART:xxxxx
DTEND:xxxx
SUMMARY:Summary
ORGANIZER:MAILTO:xx@xx.com
ATTENDEE;ROLE=REQ-PARTICIPANT;RSVP=TRUE:MAILTO:x@x.com
SEQUENCE:0
END:VEVENT
END:VCALENDAR

自动邮件应在接受日历邀请后触发组织者

这是我的Java代码:

public void sendTestEvent(final MailAudit mail) {
    MimeMessagePreparator preperator = new MimeMessagePreparator() {
        public void prepare(MimeMessage mimeMessage) throws Exception {
            mimeMessage.addHeaderLine("method=REQUEST");
            mimeMessage.addHeaderLine("charset=UTF-8");
            mimeMessage.addHeaderLine("component=VEVENT");
            mimeMessage.setFrom(new InternetAddress("xx@xx.com"));
            mimeMessage.addRecipient(Message.RecipientType.TO, new InternetAddress("xx@xx.com"));
            mimeMessage.setSubject("Calendar");
            BodyPart messageBodyPart = new MimeBodyPart();
            messageBodyPart.setHeader("Content-Class", "urn:content-  classes:calendarmessage");
                    messageBodyPart.setHeader("Content-ID", "calendar_message");
                messageBodyPart.setDataHandler(new DataHandler(
                        new ByteArrayDataSource("icsFileContent", "text/calendar")));// very important
                    Multipart multipart = new MimeMultipart();
            multipart.addBodyPart(messageBodyPart);
            mimeMessage.setContent(multipart);

        }
    };
    mailSender.send(preperator);
}

0 个答案:

没有答案