get screen output to file using get_payload()

Lee Harr missive at frontiernet.net
Wed Jun 23 16:52:10 EDT 2004


On 2004-06-23, chuck amadi <chuck.amadi at ntlworld.com> wrote:
>      Hi I have managed to print the output of the get_payload to screen
> but I need to write to a file as I only require the email body messages
> from the mailbox.My script using the fp.readlines() function writes the
> entire contents of the mailbox of cause including the headers of the
> emails I do not want.
>
> I have tried a few things but I cant get to my goal.Any ideas or
> pointers I need only the email body and I cant figute out why I can
> using the print statement but get those results to a file.
> cheers
>

> mailout = file("/home/chucka/pythonScript/SurveyResults1.txt","r")
>                


You have the file opened read only. You would need something like:

mailout = file("/home/chucka/pythonScript/SurveyResults1.txt", "w")




More information about the Python-list mailing list