nephish wrote:
> Does anyone know how to strip everything off of an email?
> i have a little app that i am working on to read an email message and
> write the
> body of a message to a log file.
> each email this address gets is only about three to five lines long.
> but i cannot seem to get just the body filtered through.
> i get all the headers, the path, what spam-wall it went through, etc...
>
> any suggestions would be greatly appreciated .
> thanks
> _______________________________________________
> Tutor maillist - [email protected]
> http://mail.python.org/mailman/listinfo/tutor
>
THis is from the email module. If I remember correctly text is the first
part of the payload in a multipart that has text. So if you know it
comes in that way you can grab it with the optional i=0. If it isn't
and you know it's coming in as a string just get the string and write it
to the log.
Then again someone else may have a better answer...
get_payload( [i[, decode]])
Return a reference the current payload, which will be a list of
Message objects when is_multipart() is True, or a string when
is_multipart() is False. If the payload is a list and you mutate the
list object, you modify the message's payload in place.
With optional argument i, get_payload() will return the i-th element
of the payload, counting from zero, if is_multipart() is True. An
IndexError will be raised if i is less than 0 or greater than or equal
to the number of items in the payload. If the payload is a string (i.e.
is_multipart() is False) and i is given, a TypeError is raised.
Optional decode is a flag indicating whether the payload should be
decoded or not, according to the Content-Transfer-Encoding: header. When
True and the message is not a multipart, the payload will be decoded if
this header's value is "quoted-printable" or "base64". If some other
encoding is used, or Content-Transfer-Encoding: header is missing, or if
the payload has bogus base64 data, the payload is returned as-is
(undecoded). If the message is a multipart and the decode flag is True,
then None is returned. The default for decode is False.
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor