Parsing the body of an email

  • Thread starter BoBo the monkey
  • Start date
B

BoBo the monkey

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
 
J

John Roth

BoBo the monkey said:
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
 
C

Cameron Laird

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,008
Latest member
HaroldDark

Latest Threads

Top