Reputation: 426
I have written java code to send calendar invite. It works good with gmail, thunderbird. The clients read the ics and show the invitation properly.
But the same mail doesn't seem to be working on Microsoft Outlook. Outlook doesn't recognize the mail as calendar invite and hence no accept, reject buttons are shown.
Following is the code snippet used:
MimeMessage message = new MimeMessage(session);
message.addHeaderLine("method=REQUEST");
message.addHeaderLine("charset=UTF-8");
message.addHeaderLine("component=VEVENT");
BodyPart textBodyPart = new MimeBodyPart();
textBodyPart.setContent("Invitation for an event.", "text/plain");
BodyPart messageBodyPart = new MimeBodyPart();
messageBodyPart.addHeader("Content-Class", "urn:content-classes:calendarmessage");
messageBodyPart.addHeader("Content-ID", "calendar_message");
messageBodyPart.setContent(inviteMessage, "text/calendar");
Multipart multipart = new MimeMultipart("alternative");
multipart.addBodyPart(textBodyPart);
multipart.addBodyPart(messageBodyPart);
message.setContent(multipart);
The ics file that I'm sending is:
BEGIN:VCALENDAR
VERSION:1.0
PRODID:-//Michael Angstadt//biweekly 0.6.0//EN
METHOD:REQUEST
BEGIN:VEVENT
DTSTAMP:20170123T115919Z
ORGANIZER:mailto:[email protected]
UID:12345678
COMMENT:Event Invitation
DTSTART:20170123T120319Z
SUMMARY;LANGUAGE=en-us:Event Invitation
DURATION:PT30M
ATTENDEE;RSVP=TRUE;ROLE=CHAIR;PARTSTAT=NEEDS-ACTION;CN=XY:mail
to:[email protected]
END:VEVENT
END:VCALENDAR
Found similar problems on stackoverflow, tried the mentioned solutions but nothing helped. Multipart email with text and calendar: Outlook doesn't recognize ics
Sending Outlook meeting requests without Outlook?
Java, ICS calendar format not showing time when imported in Outlook or Thunderbird
Upvotes: 0
Views: 1732
Reputation: 376
Modifying content type as below did trick for me.
messageBodyPart.setContent(inviteMessage, "text/calendar;method=REQUEST");
Upvotes: 2