csv附件不完整python

时间:2018-08-03 14:29:15

标签: python python-2.7 email-attachments

所以这是发送csv文件的imy代码,我有7 kb的文件,此代码发送了文件,但将其切成4 kb的大小,第14行之后的行丢失了。我需要解决此问题的帮助。

from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
from email.MIMEBase import MIMEBase
from email import encoders



fromaddr = "xxxx"
toaddr = "xxxx"

msg = MIMEMultipart()

msg['From'] = fromaddr
msg['To'] = toaddr
msg['Subject'] = "Report"

body = "SSL Scan"

msg.attach(MIMEText(body, 'plain'))

filename = "inp.csv"
attachment = open("C:\inp.csv", "rb")

part = MIMEBase('application', 'octet-stream')
csv.reader=part.set_payload((attachment).read())
encoders.encode_base64(part)
part.add_header('Content-Disposition', "attachment; filename= %s" % filename)

msg.attach(part)

server = smtplib.SMTP('smtp-mail.outlook.com', 587)
server.starttls()
server.login(fromaddr, "xxxx")
text = msg.as_string()
server.sendmail(fromaddr, toaddr, text)
server.quit()

0 个答案:

没有答案