Decoding MIME email

Discussion in 'Python' started by Thomas Williams, Aug 26, 2003.

  1. Thanks, I tried it and it stop at:
    f = file("mail.txt")
    with the error message.

    TypeError: 'str' object is not callable


    Tom Williams


    -------- Original Message --------
    Subject: Re: Decoding MIME email.
    Date: Tue, 26 Aug 2003 01:40:07 +0200
    From: Gerhard Häring <>
    To:
    References:
    <>



    Thomas Williams wrote:
    Hello everyone, my name is Tom W. And, I am new to
    the
    list, and have been using Python for about a year now.
    Anyway, I got a question! I am trying to decode MIME
    (base64) email from a POP3 server, but all I get is a
    corrupt file. [...]

    You should be using the email module for this. Here
    are a few interactive commands that could get you
    started:



    from email.Parser import Parser
    f = file("/tmp/mail.txt")
    parser = Parser()
    msg = parser.parse(f)
    f.close()
    msg
    <email.Message.Message instance at 0x8195e34>

    You probably can figure out the rest with the
    documentation for the email module, otherwise just ask
    here.

    Oh, and if your Python doesn't have an email module,
    it's really time to upgrade :)

    -- Gerhard

    --
    http://mail.python.org/mailman/listinfo/python-list
     
    Thomas Williams, Aug 26, 2003
    #1
    1. Advertising

  2. Thomas Williams

    Tim Roberts Guest

    Thomas Williams <> wrote:
    >
    >Thanks, I tried it and it stop at:
    >f = file("mail.txt")
    >with the error message.
    >
    >TypeError: 'str' object is not callable


    I'll wager you have a line something like this before that:

    file = sys.argv[0]
    ....
    f = file("mail.txt")

    Either do not use variables called "file", or replace the "file" with
    "open" in your function call.
    --
    - Tim Roberts,
    Providenza & Boekelheide, Inc.
     
    Tim Roberts, Aug 28, 2003
    #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. Mad Scientist Jr

    decoding MIME attachments?

    Mad Scientist Jr, Nov 11, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    664
    Bruce Barker
    Nov 11, 2005
  2. Thomas Williams

    Decoding MIME email.

    Thomas Williams, Aug 25, 2003, in forum: Python
    Replies:
    1
    Views:
    457
    Sybren Stuvel
    Aug 25, 2003
  3. =?ISO-8859-1?Q?Gerhard_H=E4ring?=

    Re: Decoding MIME email.

    =?ISO-8859-1?Q?Gerhard_H=E4ring?=, Aug 26, 2003, in forum: Python
    Replies:
    0
    Views:
    394
    =?ISO-8859-1?Q?Gerhard_H=E4ring?=
    Aug 26, 2003
  4. cayenne
    Replies:
    3
    Views:
    271
    Brian McCauley
    May 26, 2004
  5. ecureuil
    Replies:
    0
    Views:
    357
    ecureuil
    May 28, 2006
Loading...

Share This Page