MimeWriter and encode64 with zope file objs
I want to attach zope file objects (CMF Portal File) to a multipart email like this: for fileId in attachments: file = getattr(self, fileId) part = writer.nextpart() #part.addheader('Content-Transfer-Encoding', 'none') part.addheader('Content-Transfer-Encoding', 'base64') body = part.startbody ( file.getContentType() + '; name=' + file.id() ) #body.write(str(file)) base64.encode (file, body) This works fine with no encoding and text data, but binary data needs encoding. encode64 will not encode as the zope file has no read() method. Should i write my own wrapper class, or is there a simpler way?? TIA
drew nichols wrote at 2003-6-5 09:40 +1000:
... base64.encode (file, body)
This works fine with no encoding and text data, but binary data needs encoding. encode64 will not encode as the zope file has no read() method. Should i write my own wrapper class, or is there a simpler way??
If your files are not too large, you can use "encode_string" and convert the "file" into a string with "str(file.data)". Dieter
participants (2)
-
Dieter Maurer -
drew nichols