faqts : Computers : Programming : Languages : Python : Common Problems : Email

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

11 of 12 people (92%) answered Yes
Recently 8 of 9 people (89%) answered Yes

Entry

How can I get a message's flag (Unread, Seen, Reply...) using Imaplib?

Aug 24th, 2000 20:08
unknown unknown, Donn Cave


Assuming srv is an instance of IMAP4, and you want both flags and 
headers for messages 1 through 5 in the currently selected folder -
      status, result = srv.fetch('1:5', '(FLAGS RFC822.HEADER)')
Now you have in "result" a sequence of strings, with all the 
information you requested.  It's not broken up in the most convenient 
way for you -- you will need to use some string functions to extract 
the flags and everything.