Im creating an email with a text/calendar type. It has 3 alternate views: text, html, and the last is the meeting invite or .ics. I am not attaching the ics, but rather placing it in the content of the third view.
When I send it, outlook 2013 correctly receives the invite and shows the Accept/Tentative/Decline buttons at the top of the message.
However when I try to embed an attachment into the event/meeting it simply doesnt grab it.
If I send the ics as an attachment, it will have them embeded attachment, however users will have to click on the .ics file instead of getting the inline Accept/Tentative/Decline.
Im generating this in a scripting language called tcl. Im using the mime and smtp libraries. I've been referencing tcl, c#, php, and java implementations, and it doesnt seem that anyone has documented this exact scenario.
I can post my code if needed, however its pretty irrelevant. What is relevant is the mime message being built.
How do I embed an attachment into an event/calendar item?
MIME-Version: 1.0
Content-ID: <30261.1428705114.6@cleaf1.mydomain.org>
Content-Type: multipart/related;
boundary="----- =_D0iKdgI+3r1IL2tYlWQ+zA=="
------- =_D0iKdgI+3r1IL2tYlWQ+zA==
MIME-Version: 1.0
Content-ID: <30261.1428705114.4@cleaf1.mydomain.org>
Content-Type: multipart/alternative;
boundary="----- =_6M80yPWZSMRuPfyOccOhUw=="
------- =_6M80yPWZSMRuPfyOccOhUw==
MIME-Version: 1.0
Content-ID: <30261.1428705114.1@cleaf1.mydomain.org>
Content-Type: text/plain;
charset="utf-8"
Content-Transfer-Encoding: 8bit
Plain Text
Line2
------- =_6M80yPWZSMRuPfyOccOhUw==
MIME-Version: 1.0
Content-ID: <30261.1428705114.2@cleaf1.mydomain.org>
Content-Type: text/html;
charset="utf-8"
Content-Transfer-Encoding: 8bit
html
line2
------- =_6M80yPWZSMRuPfyOccOhUw==
MIME-Version: 1.0
Content-ID: <30261.1428705114.3@cleaf1.mydomain.org>
Content-Type: text/calendar;method=request; charset="utf-8";
charset="utf-8"
Content-Transfer-Encoding: 8bit
BEGIN:VCALENDAR
PRODID:-//Microsoft Corporation//Outlook 15.0 MIMEDIR//EN
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:REQUEST
X-MS-OLK-FORCEINSPECTOROPEN:TRUE
BEGIN:VEVENT
ORGANIZER;CN=No Reply:mailto:NoReply@mydomain.org
ATTENDEE;CN='Todd';ROLE=REQ-PARTICIPANT;RSVP=FALSE:MAILTO:thorst2@mydomain.org
DTSTART:20150411T120000Z
DTEND:20150411T140000Z
LOCATION:
TRANSP:OPAQUE
SEQUENCE:0
UID:a526f058fba04a4067966986ce365080
DTSTAMP:20150410T223154Z
LAST-MODIFIED:20150410T223154Z
DESCRIPTION:Test Description
SUMMARY:Test Title
ATTACH;ENCODING=BASE64;VALUE=BINARY;X-FILENAME=DOC_FR_MD_in.20150317_154551
.idx.gz:H4sICE9oCFUCA0RPQ19GUl9NRF9pbi4yMDE1MDMxN18xNTQ1NTEuaWR4AO2Wz47bIB
DG732KeQTAhjhHYnBi1f8Wxqvd00pVL71sT5UqWX73QtbZQpJVWm9UbRVzwh/MxzBj/+RhqEsF
w6DaWpYNEBhh2PUbNwE/bfoaGCMs9c8wjk6yJo9ChnEKGcbXED99GfsQfOw0KInSr9u2N7nO26
YB1eZPhXmqFcwazqw15faqhkpb3FuR42POr2BZa6ApE4KQNedO6UzptuMjcMqId3T3LmqMw6y8
9xmjfkD49vzl+4/nr/tzisLqcGuUW6WbLe6AUk75QSsqubVAfhKSEcK8M0rUL33cmrbv/rZXDx
XizmipgoW5xTQaTant0dU/l507BHxtequNq8O9NmoD7JCyy/ikxi75qMpe8y5e5IJknE1i258R
7/LenHreYYunqkvo1MBie8ZAmjwW1QblptLvLd3/PnyXdZfvpDnqvTKl63WOFYgskP1rsMdDsH
n8NPwBmlIqErqg6QKaKEnF+jpocvDJkrfRJIhIbxVNhyqHaIp4dUBTJM5BU2SwoOljosl9Y2y9
oOkSmmhGVtdBE1utpv+is2ji7qybRdNU5QhNIa9e0RSKs9AUGixo+qBoYpTzBU2X0JQmnF4HTW
mSrNO30ZSsMnGzaJqqHKMp4NVvNAXiPDQFBgua/j2afgGbA8R2bBIAAA==
PRIORITY:5
TRANSP:FREE
X-MICROSOFT-CDO-BUSYSTATUS:FREE
X-MICROSOFT-CDO-IMPORTANCE:1
X-MICROSOFT-DISALLOW-COUNTER:FALSE
X-MS-OLK-AUTOFILLLOCATION:TRUE
X-MS-OLK-CONFTYPE:0
CLASS:PUBLIC
END:VEVENT
END:VCALENDAR
------- =_6M80yPWZSMRuPfyOccOhUw==--
------- =_D0iKdgI+3r1IL2tYlWQ+zA==--
This is generated by the mime library, and as i said if i send as an attachment it works. It just doesnt work when using text/calendar;method=REQUEST and placing it in an alternative view
I suspect its with my mime message (email) structure or it headers
Update 1:
Here is my new code, per recommendation to have a flatter structure. With or without the content type having charset and with or without content transfer, didnt seem to make a difference. The email still is received, and presents the Accept/Tentative/Decline buttons, but no attachment:
MIME-Version: 1.0
Content-ID: <12516.1428711300.1@cleaf1.mydomain.org>
Content-Type: text/calendar;
charset="utf-8"
Content-Transfer-Encoding: 8bit
BEGIN:VCALENDAR
PRODID:-//Microsoft Corporation//Outlook 15.0 MIMEDIR//EN
VERSION:2.0
METHOD:REQUEST
BEGIN:VEVENT
DTSTART:20150411T120000Z
DTEND:20150411T140000Z
SEQUENCE:0
UID:54690bbc05124b2e7c4ad5d480025278
DTSTAMP:20150411T001500Z
LAST-MODIFIED:20150411T001500Z
DESCRIPTION:Test appointment body
SUMMARY:Test Title
ATTACH;ENCODING=BASE64;VALUE=BINARY;X-FILENAME=DOC_FR_MD_in.20150317_154551
.idx.gz:H4sICE9oCFUCA0RPQ19GUl9NRF9pbi4yMDE1MDMxN18xNTQ1NTEuaWR4AO2Wz47bIB
DG732KeQTAhjhHYnBi1f8Wxqvd00pVL71sT5UqWX73QtbZQpJVWm9UbRVzwh/MxzBj/+RhqEsF
w6DaWpYNEBhh2PUbNwE/bfoaGCMs9c8wjk6yJo9ChnEKGcbXED99GfsQfOw0KInSr9u2N7nO26
YB1eZPhXmqFcwazqw15faqhkpb3FuR42POr2BZa6ApE4KQNedO6UzptuMjcMqId3T3LmqMw6y8
9xmjfkD49vzl+4/nr/tzisLqcGuUW6WbLe6AUk75QSsqubVAfhKSEcK8M0rUL33cmrbv/rZXDx
XizmipgoW5xTQaTant0dU/l507BHxtequNq8O9NmoD7JCyy/ikxi75qMpe8y5e5IJknE1i258R
7/LenHreYYunqkvo1MBie8ZAmjwW1QblptLvLd3/PnyXdZfvpDnqvTKl63WOFYgskP1rsMdDsH
n8NPwBmlIqErqg6QKaKEnF+jpocvDJkrfRJIhIbxVNhyqHaIp4dUBTJM5BU2SwoOljosl9Y2y9
oOkSmmhGVtdBE1utpv+is2ji7qybRdNU5QhNIa9e0RSKs9AUGixo+qBoYpTzBU2X0JQmnF4HTW
mSrNO30ZSsMnGzaJqqHKMp4NVvNAXiPDQFBgua/j2afgGbA8R2bBIAAA==
END:VEVENT
END:VCALENDAR
Update #2 (Solution)
I marked the reply as the answer because it helped me find the solution. I've posted the solution in the question because I wanted to still give credit to @DmitryStreblechenko for helping me
Here is the tcl code:
#######################################################
# Initial Setup
#######################################################
#Import packages
package require uuid
package require mime
package require smtp
#Set up basic appointment template
set tmplICS "BEGIN:VCALENDAR
PRODID:-//Microsoft Corporation//Outlook 15.0 MIMEDIR//EN
VERSION:2.0
METHOD:REQUEST
BEGIN:VEVENT
DTSTART:@start
DTEND:@end
SEQUENCE:0
UID:@uid
DTSTAMP:@created
LAST-MODIFIED:@created
DESCRIPTION:Test appointment body
SUMMARY:@summary
END:VEVENT
END:VCALENDAR"
#######################################################
# Real Data
#######################################################
#Setup data for substitution
set uuid [string map {- ""} [uuid::uuid generate]]
#Now in utc
set created [clock format [clock seconds] -format {%Y%m%dT%H%M%SZ} -timezone :UTC]
#Get todays date at 8, then add a day, then convert to utc
set est [clock scan [clock format [clock seconds] -format {%Y%m%dT080000}]]
set est [clock add $est 1 day]
set utcStart [clock format $est -format {%Y%m%dT%H%M%SZ} -timezone :UTC ]
#Get todays date at 10, then add a day, then convert to utc
set est [clock scan [clock format [clock seconds] -format {%Y%m%dT100000}]]
set est [clock add $est 1 day]
set utcEnd [clock format $est -format {%Y%m%dT%H%M%SZ} -timezone :UTC ]
#######################################################
# Compile Data
#######################################################
#Fill in the template
set mapper ""
lappend mapper "@uid" $uuid
lappend mapper "@start" $utcStart
lappend mapper "@end" $utcEnd
lappend mapper "@created" $created
lappend mapper "@summary" "Test Title"
set appointment [string map $mapper $tmplICS]
#######################################################
# Set up the bodies
#######################################################
#set up text and meeting request bodies
set text [mime::initialize -canonical text/plain -string "hey"]
set html [mime::initialize -canonical text/html -string "<b>hey</b>"]
set token [mime::initialize -canonical "text/calendar;charset=\"utf-8\";method=REQUEST" -string $appointment]
#Set up container
set mimeBodies [mime::initialize -canonical multipart/alternative -parts [list $text $html $token]]
#######################################################
# Set up attachments
#######################################################
set att [mime::initialize -canonical "application/octet-stream; name=\"ReadMePlease.txt\"" \
-file "/qdxiprod/cis6.1/integrator/web/readme.txt" \
-header [list Content-Disposition "attachment"] ]
set att1 [mime::initialize -canonical "application/hmtl; name=\"DOC_FR_MD.html\"" \
-file "/qdxiprod/cis6.1/integrator/testhtmlFile.html" \
-header [list Content-Disposition "attachment"] ]
#######################################################
# Finish the setup
#######################################################
#Bodies and attachments
set mimeSum [mime::initialize -canonical multipart/mixed -parts [list $mimeBodies $att $att1]]
#Output what it looks like
echo [::mime::buildmessage $mimeSum]
#The sum of the mime package looks like this
#multipart/mixed
# multipart/alternative (holding the two forms of the body part)
# text/plain
# text/html
# text/calendar;method=REQUEST
# application/octet-stream (attachment #1)
# application/html (attachment #2)
#Send email
smtp::sendmessage $mimeSum -servers "smtp.mydomain.org" -header [list From "NoReply@mydomain.org"] -header [list To "myemail@mydomain.org"]
#Destroy mime package
mime::finalize $mimeSum
Here is the mime package:
MIME-Version: 1.0
Content-ID: <20418.1428888890.7@server1.mydomain.org>
Content-Type: multipart/mixed;
boundary="----- =_FoyUc668JaIKjlKQbXOmqQ=="
------- =_FoyUc668JaIKjlKQbXOmqQ==
MIME-Version: 1.0
Content-ID: <20418.1428888890.4@server1.mydomain.org>
Content-Type: multipart/alternative;
boundary="----- =_1trMjc6PUm3+p04m/SU8aA=="
------- =_1trMjc6PUm3+p04m/SU8aA==
MIME-Version: 1.0
Content-ID: <20418.1428888890.1@server1.mydomain.org>
Content-Type: text/plain
hey
------- =_1trMjc6PUm3+p04m/SU8aA==
MIME-Version: 1.0
Content-ID: <20418.1428888890.2@server1.mydomain.org>
Content-Type: text/html
hey
------- =_1trMjc6PUm3+p04m/SU8aA==
MIME-Version: 1.0
Content-ID: <20418.1428888890.3@server1.mydomain.org>
Content-Type: text/calendar;charset="utf-8";method=request
BEGIN:VCALENDAR
PRODID:-//Microsoft Corporation//Outlook 15.0 MIMEDIR//EN
VERSION:2.0
METHOD:REQUEST
BEGIN:VEVENT
DTSTART:20150413T120000Z
DTEND:20150413T140000Z
SEQUENCE:0
UID:56b39b14ebb641ab7de716a62bed46aa
DTSTAMP:20150413T013450Z
LAST-MODIFIED:20150413T013450Z
DESCRIPTION:Test appointment body
SUMMARY:Test Title
END:VEVENT
END:VCALENDAR
------- =_1trMjc6PUm3+p04m/SU8aA==--
------- =_FoyUc668JaIKjlKQbXOmqQ==
MIME-Version: 1.0
Content-Disposition: attachment
Content-ID: <20418.1428888890.5@server1.mydomain.org>
Content-Type: application/octet-stream; name="readmeplease.txt"
Content-Transfer-Encoding: base64
MSAyNCBDdXN0b21pemUuZXhlLm1hbmlmZXN0
------- =_FoyUc668JaIKjlKQbXOmqQ==
MIME-Version: 1.0
Content-Disposition: attachment
Content-ID: <20418.1428888890.6@server1.mydomain.org>
Content-Type: application/hmtl; name="doc_fr_md.html"
Content-Transfer-Encoding: base64
MSAyNCBDdXN0b21pemUuZXhlLm1hbmlmZXN0
------- =_FoyUc668JaIKjlKQbXOmqQ==--