0

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:x@y.com 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:x.y@gmail.com 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

Community
  • 1
  • 1
Mahesh Gosemath
  • 416
  • 1
  • 4
  • 12
  • Have you tried to export an original Outlook-invitation to ICS and checked its attributes? – IQV Jan 27 '17 at 09:39
  • Yes, did that too. Didn't work. Also manually created an event with google calendar and sent invitation to email configured on outlook. Outlook could recognize that invitation so hardcoded the gmail ics in code and tried but that too didn't work. – Mahesh Gosemath Jan 27 '17 at 09:59

1 Answers1

2

Modifying content type as below did trick for me.

messageBodyPart.setContent(inviteMessage, "text/calendar;method=REQUEST");
swaz
  • 321
  • 2
  • 5