hi all,
my problem is to get a tiff-file-attachment out of an email sent by a
fax-server.
When i try this with "get_payload(decode='True')" i get additional informations, looks like binary-mixed header-information, enveloping the tiff-data.
get_payload(decode=1) returns the decoded data. eg. the "binary" value of a file attachement.
If you get additional information there is most likely something wrong with your message, or you are not traversing it correctly.
You should do something like::
# untested
def getAttachments(message): "Returns attachments from message" maintype = message.get_type() if maintype == 'application/octet-stream' : return [message.get_payload(decode=1)] if message.is_multipart(): attachments = [] for part in message.walk(): attachments.append(part.get_payload(decode=1)) return attachments return []
--
hilsen/regards Max M, Denmark
http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list