Hi I've just found out that I can't use smtplib to send emails from GAE, but I need to specify custom mime-types as in:
part = MIMEBase('application', "vnd.openxmlformats-officedocument.wordprocessingml.document")
part.set_payload( doc )
Encoders.encode_base64(part)
part.add_header('Content-Disposition', 'attachment; filename="%s"' % "ackReceived.docx")
msg.attach(part)
If I try to use the api in the documented way it sends the attachment with 'application/msword' which is causing my docx to corrupt.
Can I specify the mime-type manually using google's mail api?
Edit: A little more about the problem I face when my docx is sent by mail api:
smtplib sends the attachment like this:
Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="ackReceived.docx"
UEsDBBQABgAIAAAAIQCCVgdJnwEAAMgIAAATAAAAW0NvbnRlbnRfVHlwZXNdLnhtbMWWS0/DMBCE
70j8h8hXlLhwQAg17YHHEZAo4mzsTWMRP2Qvj/571k1bIaiaiDbiEilZz3wzsSJnPP00TfYOIWpn
S3ZajFgGVjql7bxkT7Pb/IJlEYVVonEWSraAyKaT46PxbOEhZqS2sWQ1or/kPMoajIiF82BpUrlg...
Google mail api sends the same file like this:
Content-Type: application/msword
MIME-Version: 1.0
Content-Disposition: attachment; filename="ackReceived.docx"
PK�����!�‚VIŸ��È�����[Content_Types].xmlÅ–KOÃ0„ïHü‡ÈW”¸p@5íÇ(âlìMc?d/þ{ÖM[!¨šˆ6â)YÏ|3±"g<ý4Mö!jgKvZŒXV:¥í¼dO³Ûü‚e…U¢qJ¶€È¦“ã£ñlá!f¤¶±d5¢¿ä<ÊŒˆ…ó`iR¹`Òm˜s/䫘?ιtÁbŽÉƒMÆ×P‰·³›OzÜ&!9Ë®Úu U2á}£¥@ó4å[uÞÎè´IÜô|»"@w ÞúÑ'_u)H¹\kíãÉ*Ó=½Ì d"à0dÇ?\P\9ùfQì®¶…çªJKØè“›NBŒ´K¦)6#´íÌqÑ@<|ŠÖ·'þYc}SU ±Oó¤-~i»i€Hñ†¨»rîŒð/ƒ¥øfÞ¤rÃ!ö~cݬ(ÃÚ¹3B
BA8=|‚Ö¸'ÿìßøi³éß÷äп7Ÿxâ¥!¬¬;C ”Ð^÷߉¥Í.$|ÎG:yÃj¯¼¤Î©°‡€z÷—¶!’õÞý Ö...