Parsing the body of an email

Discussion in 'Python' started by BoBo the monkey, Nov 8, 2003.

  1. I would like to know if anyone out there can give me an example or any
    help with this. Using Python, I need to take the body of an email,
    which has already been saved as a string, and parse it up into
    different pieces which exist in said body.

    =============================
    Example:
    This is basically what the email body looks like, simplified of
    course.
    .....
    Summary:
    ========
    This is the summary of the email.


    Content:
    ========
    This is another section of content in the email.


    Date:
    ========
    November 08, 2003
    .....
    =============================

    I need to take out the detail of each section and save them as
    seperate strings to be used elsewhere.

    If anyone has any code examples that can get me started, or advice, or
    any help at all it would be greatly appriciated. I'm very much a
    novice in regards to Python and just don't know the language that well
    yet.

    Thanks in advance,
    Cory
    BoBo the monkey, Nov 8, 2003
    #1
    1. Advertising

  2. BoBo the monkey

    John Roth Guest

    "BoBo the monkey" <> wrote in message
    news:...
    > I would like to know if anyone out there can give me an example or any
    > help with this. Using Python, I need to take the body of an email,
    > which has already been saved as a string, and parse it up into
    > different pieces which exist in said body.


    See the email package under the Internet Data Handling
    section of the Python Library Reference. It's section 12.2
    in the Python 2.2.3 manual set.

    John Roth
    John Roth, Nov 8, 2003
    #2
    1. Advertising

  3. In article <>,
    John Roth <> wrote:
    >
    >"BoBo the monkey" <> wrote in message
    >news:...
    >> I would like to know if anyone out there can give me an example or any
    >> help with this. Using Python, I need to take the body of an email,
    >> which has already been saved as a string, and parse it up into
    >> different pieces which exist in said body.

    >
    >See the email package under the Internet Data Handling
    >section of the Python Library Reference. It's section 12.2
    >in the Python 2.2.3 manual set.
    >
    >John Roth
    >
    >


    Mr. Roth, if I understand BoBo's original posting, his question
    actually has nothing to do with e-mail, in our terms; he's just
    trying to parse a long string that happened to originate within
    an e-mail system.

    BoBo, you described your message as segmented into several sec-
    tions. Do they always appear in the same order? If so, a
    regular expression will probably be handiest for this job. If
    not, you'll build a simple, simple finite-state machine, and
    feed it the message a line at a time.
    --

    Cameron Laird <>
    Business: http://www.Phaseit.net
    Cameron Laird, Nov 9, 2003
    #3
    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. Mike John
    Replies:
    1
    Views:
    539
    Natty Gur
    Jul 2, 2003
  2. London Boy
    Replies:
    2
    Views:
    330
    Keith Bowes
    Jan 12, 2004
  3. Replies:
    5
    Views:
    209
    A. Sinan Unur
    Sep 8, 2005
  4. Emile van Sebille

    Re: mbox parsing, specifically message body

    Emile van Sebille, Jun 14, 2012, in forum: Python
    Replies:
    0
    Views:
    241
    Emile van Sebille
    Jun 14, 2012
  5. Dennis Lee Bieber

    Re: mbox parsing, specifically message body

    Dennis Lee Bieber, Jun 15, 2012, in forum: Python
    Replies:
    0
    Views:
    376
    Dennis Lee Bieber
    Jun 15, 2012
Loading...

Share This Page