simple script to read and parse mailbox
chuck amadi
chuck.amadi at ntlworld.com
Sun Jun 6 06:15:22 EDT 2004
fishboy wrote:
>On Sat, 05 Jun 2004 15:27:36 +0100, chuck amadi
><chuck.amadi at ntlworld.com> wrote:
>
>
>
>>Hi , Im trying to parse a specific users mailbox (testwwws) and output
>>the body of the messages to a file ,that file will then be loaded into a
>>PostGresql DB at some point .
>>
>>I have read the email posts and been advised to use the email Module
>>and mailbox Module.
>>
>>The blurb from a memeber of this list . Im not at work at the moment So
>>I cant test this out , but if someone could take a look and check that
>>im on the write track as this Monday I need to show my Boss and get the
>>body data out of the user's mailbox.
>>
>>**Blurb form a member who's directed me**
>>
>>Thus started with the mailbox and email modules. Mailbox lets you iterate over a
>>mailbox yielding individual messages of type email. The e-mail object lets
>>you parse and operate on the message components. From there you should be
>>able to extract your data.
>>
>>
>>
>
>Hi again Chuck,
>
>I've been reading a few of your posts and I'm wondering. Are the
>emails that you're parsing have binary attachments, like pictures and
>stuff, or are you just trying to get the text of the body?
>
>Or is it a little of both? It looks like you're expecting emails with
>multiple binary attachments.
>
>Other than that it looks good. You can access the header fields
>directly, like:
>
>print msg['From']
>
>Save you a little typing.
>
>
>
>><{{{*>
>>
>>
>
>
>
Well I did hack most of the code . I was trying using the mboxutils
module but I could only get the headers . I assume form this script I
can get the text of the body . The reason I haven't tested is while at
work I started the write (Oops Hack ) the script then emailed it home .
Because I use pop3 account I onlt have a /var/spool/mail/Chucka not as
in work /home/User/Mail/inbox that I usuaslly scan to view data in inbox.
So please re-affirm that my hack script will be able to parse the text
of the body ( No attachments of binaries will exist within the email
messages.
Cheers for you help.
print msg['Body']
I just need the text of the body. But from your psi I can -
More information about the Python-list
mailing list