Hey folks,
So I set up a couple of my apps (python) to receive email. The
tutorial on the appengine developer's guide is not too clear on
decoding emails. My problem is being able to get strictly the text of
the most recent email in a thread. Currently I'm decoding the 1st
plain-text body of a received email, but this seems to include all the
emails in the thread (shows up under the "show quoted text" link in
gmail).
Here is the code I'm using:
bodies = message.bodies(content_type='text/plain')
decoded = False
for body in bodies:
if not decoded:
decoded_body = body[1].decode()
decoded = True
Also there seem to be endlines where there shouldn't be. Do email
clients like gmail automatically add them?
Basically I just want the text of the email with only the endlines
explicitly entered by the message sender. Seems simple enough..
Currently I'm resorting to starting with the 'text/html' bodies and
using the following hack:
decoded_body.split('<br><br><div class="gmail_quote">')
text = decoded_body[0]
It works for gmail, but obviously won't for any other client.
Arjun
--
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-appengine?hl=en.