MIMEMultipart cuts attached file

  • Thread starter Achim Domma (Procoders)
  • Start date
A

Achim Domma (Procoders)

Hi,

I try to send a mulitpart email, which should have a body and two
attached files: a html file and a zip file. My code looks like this:



msg=MIMEMultipart()
msg['From']=sender
msg['To']='; '.join(recipients)
msg['Subject']=subject
msg.epilogue=''

html=file(reportFile,'rb').read()
report=MIMEText(html,'html')
report.add_header('Content-Disposition','attachment',filename=reportFile)
msg.attach(report)

data=file(diffFile,'rb').read()
diff=MIMEBase('application','zip')
diff.set_payload(data)
encode_base64(diff)
diff.add_header('Content-Disposition','attachment',filename=diffFile)
msg.attach(diff)

text=MIMEText("the body text",'plain')
msg.attach(text)

smtp=smtplib.SMTP('pop_server')
smtp.set_debuglevel(0)
smtp.sendmail(sender,recipients,msg.as_string())
smtp.quit()



The body of the mail is ok and the zip archive is also valid, but the
end of the html is cut of most of the time.

Any hints what I'm doing wrong?

regards,
Achim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top