Python Forum
get number of unread emails + email text
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
get number of unread emails + email text
#1
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!)

for i in range(0, unread):
    saveFileName = str(i) + emailText
    open(saveFileName + '.txt', "w")
    message =  msg.get_payload()
    saveFileName.write(message)
    saveFileName.close
Reply


Messages In This Thread
get number of unread emails + email text - by Pedroski55 - Oct-04-2018, 08:40 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
Brick Number stored as text with openpyxl CAD79 2 518 Apr-17-2024, 10:17 AM
Last Post: CAD79
  Sending Emails on Autopilot Gyga_Hawk 3 1,722 Mar-15-2022, 08:20 AM
Last Post: Larz60+
  Search text in PDF and output its page number. atomxkai 21 9,122 Jan-21-2022, 06:20 AM
Last Post: snippsat
  Trying out the parsing/reading of emails from my outlook cubangt 0 6,237 Jan-12-2022, 08:59 PM
Last Post: cubangt
  Extracing unique email address from a folder of emails jehoshua 6 2,796 Oct-14-2020, 12:43 AM
Last Post: jehoshua
  reading shared outlook emails zarize 0 2,473 Mar-03-2020, 01:47 PM
Last Post: zarize
  Python Library for Reading POP Emails? bmccollum 1 3,671 Jan-06-2020, 06:37 PM
Last Post: micseydel
  Read in trades from emails semantina 2 2,137 Nov-06-2019, 06:12 PM
Last Post: semantina
  Split Column Text by Number of Characters cgoldstein 3 3,035 Mar-11-2019, 01:45 PM
Last Post: perfringo
  get the number in the line in text file lateublegende 2 2,522 Jan-29-2019, 06:03 PM
Last Post: lateublegende

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020