Search code examples
python-2.7icalendarsmtplib

Creating an ICS file in python sends as a plain text email to external clients


I'm creating an ICS to attach to an email with SMTPLib and Email libraries in python. When I send the meeting request, it shows as a meeting request normally should inside of our organization. When I send the meeting request to people outside of the organization, it shows to those people as just a plain text email with no options to accept, decline, etc.

Pasted below is the output are the email headers being received which includes the icalendar format. Many of the possible solution I've found are that it's an error on the user's end but when I send a meeting request created in outlook and send it to an external email address, it will work fine.

Is my icalendar format incorrect?

Content-Type: multipart/mixed; boundary
MIME-Version: 1.0
Reply-To: [email protected]
Date: Fri, 15 Jun 2018 10:55:17 -0400
Subject: test
From: test <[email protected]>
To: [email protected],[email protected]

Content-Type: multipart/alternative; boundary="

MIME-Version: 1.0


Content-Type: text/html; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit

<h1>Test Email Body</h1>

MIME-Version: 1.0
Content-Type: text/calendar; method="PUBLISH"; charset="us-ascii"
Content-Transfer-Encoding: 7bit

BEGIN:VCALENDAR
PRODID://SchedulerApp//test company//en
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:REQUEST
BEGIN:VEVENT
DTSTART:20180616T074500
DTEND:20180616T084500
DTSTAMP:20180615T105517Z
ORGANIZER;CN=SchedulerApp:mailto:[email protected]
UID:FIXMEUID20180615T105517Z
ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-    PARTICIPANT;PARTSTAT=ACCEPTED;RSVP=TRUE
 ;[email protected];X-NUM-GUESTS=0:
 mailto:[email protected]
ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-    PARTICIPANT;PARTSTAT=ACCEPTED;RSVP=TRUE
 ;[email protected];X-NUM-GUESTS=0:
 mailto:[email protected]
CREATED:20180615T105517Z
<h1>Test Email Body</h1>
SEQUENCE:0
SUMMARY:test
LOCATION:test location
TRANSP:OPAQUE
END:VEVENT
END:VCALENDAR

Solution

  • For anyone that might be looking at this question, I looked at an ICS file that I saved from an outlook appointment and made that look more like what I was outputting in python. This resolved most of my issues.