Reputation: 1647
How do i attach .zip
containing multiple .csv
file. ex. text_1.csv, text_2.csv
Remember, These csv files constructed from the data in the datastore.
message = mail.EmailMessage()
message.attachments = .... #??
message.send()
Upvotes: 0
Views: 434
Reputation: 6957
do you want this???
import zipfile, StringIO
o=StringIO.StringIO()
file = zipfile.ZipFile(file=o,compression=zipfile.ZIP_DEFLATED,mode="w")
.. . ## add your csv files here
file.close()
o.seek(0)
self.response.headers['Content-Type'] ='application/zip'
self.response.headers['Content-Disposition'] = 'attachment; filename="your_csvs.zip"'
self.response.out.write(o.getvalue())
for more info visit: http://www.tareandshare.com/2008/09/28/Zip-Google-App-Engine-GAE/
Upvotes: 1