Using write function within email Module to write get_payload to afile.

Discussion in 'Python' started by Chuck Amadi, Jun 22, 2004.

  1. Chuck Amadi

    Chuck Amadi Guest

    fp = file("/home/chuck/pythonScript/testbox")

    mbox = mailbox.UnixMailbox(fp, email.message_from_file)
    # list of body messages.
    bodies = []

    # mail is the file object
    for mail in mbox:
    print mail['Subject']
    print mail.get_content_type()#text/plain
    print mail.get_payload()



    fp = file("/home/chuck/pythonScript/testbox")
    mb = mailbox.UnixMailbox(fp, email.message_from_file)

    mailout = file("/home/chuck/pythonScript/SurveyResults.txt","w")
    #for mail in fp.readlines():
    # mailout.write(mail)

    ## Something like this I have tried a few things cant get my head
    ## round it

    for bodymsg in fp:
    bodymsg= mail.get_payload()
    bodies.append(bodymsg)
    mailout.write(bodymsg)

    print "testbox mailbox file copied...to SurveyResults.txt use cat to
    view file."
    # Now close the files

    mailout.close()
     
    Chuck Amadi, Jun 22, 2004
    #1
    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:
    1
    Views:
    371
    Piet van Oostrum
    Jun 23, 2004
  2. chuck amadi
    Replies:
    0
    Views:
    347
    chuck amadi
    Jun 22, 2004
  3. lrotger
    Replies:
    0
    Views:
    456
    lrotger
    Jul 3, 2006
  4. dpapathanasiou
    Replies:
    6
    Views:
    1,050
    dpapathanasiou
    Oct 14, 2009
  5. Markus Fischer
    Replies:
    1
    Views:
    372
    Markus Fischer
    May 31, 2011
Loading...

Share This Page