Thanks a lot Alex, you are right the from email import encoders was
missing. Now it sends the email *but* without the file attached to it.
Any idea what could go wrong with this function? (I corrected other things
on it, I don't understand why it doesn't work)
def create_message_with_attachment(sender, to, subject, msgHtml, msgPlain):
msg = MIMEMultipart('alternative')
msg['To'] = to
msg['From'] = sender
msg['Subject'] = subject
msg.attach(MIMEText(msgPlain, 'plain'))
msg.attach(MIMEText(msgHtml, 'html'))
file=r"C:\Users\xx\Desktop\test_Attachment.txt"
part = MIMEBase('application', "octet-stream")
part.set_payload( open(r"file","rb").read() )
encoders.encode_base64(part)
part.add_header('Content-Disposition', 'attachment', filename=
"test_Attachment.txt")
msg.attach(part)
raw = base64.urlsafe_b64encode(msg.as_bytes())
raw = raw.decode()
body = {'raw': raw}
return body
--
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-appengine/6189a498-f826-42f4-a1a8-ad2ec93647b6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.