Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 10-04-2018, 06:26 PM   #1
Senior Member
Registered: Jan 2002
Location: Nanjing, China
Distribution: Ubuntu 18.04
Posts: 1,860

Rep: Reputation: 68
only retrieve unread messages

I am looking at using Python to access email. I really don't know much about this kind of thing.

Following this code I was surprised to find, this simple example 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 or only way to get the email text?

I only want to look at unread messages. I suppose these must be flagged somehow.
Or I could use Python to move everything to a folder 'read_messages'

I need to know how many unread messages I have. How can I get that? (Something like: unread = number of unread messages)

Then I'll run a loop like this.

for i in range(0, unread):
    saveFileName = str(i) + emailText
    open(saveFileName + '.txt', "w")
    message =  msg.get_payload()
Old 10-05-2018, 02:25 PM   #2
LQ Newbie
Registered: Dec 2005
Location: California, United States
Distribution: Qtopia on Zaurus, ArchLinuxArm on RPi, Ubuntu variants on C.H.I.P.,
Posts: 6

Rep: Reputation: 0
I see the code you reference is talking about gmail, are you talking about gmail?

If so, there is an advanced search option that might help you as a filter:



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Marking or dividing unread messages in subscribed threads yooy LQ Suggestions & Feedback 2 06-20-2010 08:33 PM
How to retrieve my old messages abd_bela Linux - Newbie 3 12-17-2009 08:54 PM
Script to get number of unread messages in gmail Geneset Linux - Software 3 10-13-2008 03:04 PM
Count of unread messages from command line rebuke Linux - Software 0 12-26-2003 06:41 PM
squirrelmail doesn't see unread messages ixion Linux - Software 0 09-14-2003 01:44 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:17 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration