Oct-04-2018, 08:40 AM
(This post was last modified: Oct-04-2018, 08:40 AM by Pedroski55.)
I am looking at using Python to access email.
Following this code I was surprised to find, it worked first time!
I am trying to save paper. What I want to do is get the actual text from the email and mark it.
On the this page he says:
"The message body can be obtained by calling msg.get_payload(), which will return the payload data as a string (if the message is not multi-part). "
Is this the best way to get the email text?
What module does msg.get_payload() belong to?
I need to know how many unread messages I have. How can I get that? (Something like: unread = number of unread messages)
Then I want to save each text in a for loop: (something like this, I've got to try it out first, don't laugh!)
Following this code I was surprised to find, it worked first time!
I am trying to save paper. What I want to do is get the actual text from the email and mark it.
On the this page he says:
"The message body can be obtained by calling msg.get_payload(), which will return the payload data as a string (if the message is not multi-part). "
Is this the best way to get the email text?
What module does msg.get_payload() belong to?
I need to know how many unread messages I have. How can I get that? (Something like: unread = number of unread messages)
Then I want to save each text in a for loop: (something like this, I've got to try it out first, don't laugh!)
for i in range(0, unread): saveFileName = str(i) + emailText open(saveFileName + '.txt', "w") message = msg.get_payload() saveFileName.write(message) saveFileName.close