tiff via email-module

Discussion in 'Python' started by Arenz, Ralph, Feb 17, 2005.

  1. Arenz, Ralph

    Arenz, Ralph Guest

    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.

    I tried the following: Sending the email from outlook to a postfix-user and
    a file on the postfix-host as well. The file shows the stucture mentioned
    above. The mail for the postfix-user is deliverd correctly. So postfix must
    fetch the raw tiff-data too!?.

    Is there a way to get the raw tiff-data using the email-module?


    Any ideas?

    ralph
     
    Arenz, Ralph, Feb 17, 2005
    #1
    1. Advertising

  2. Arenz, Ralph

    Max M Guest

    Arenz, Ralph wrote:
    > 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
     
    Max M, Feb 17, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chuck Amadi
    Replies:
    2
    Views:
    422
    chuck amadi
    Jun 6, 2004
  2. Chuck Amadi
    Replies:
    1
    Views:
    322
    fishboy
    Jun 6, 2004
  3. Nico Grubert
    Replies:
    0
    Views:
    908
    Nico Grubert
    Dec 8, 2006
  4. Fredrik Lundh
    Replies:
    0
    Views:
    463
    Fredrik Lundh
    Dec 8, 2006
  5. ifiaz
    Replies:
    1
    Views:
    1,051
    Martien Verbruggen
    Nov 19, 2003
Loading...

Share This Page