2

I am able to get inbox emails and also able to get emails from specific folder but i am unable to get "starred" emails.

I tried below code. and i am expecting emails with "starred flag" in response.

from imap_tools import MailBox, A

# Create your views here.
def temp(request):
    

    #Get date, subject and body len of all emails from INBOX folder
    with MailBox('smtp.gmail.com').login('admin@gmail.com', 'password', 'INBOX') as mailbox:
        temp="empty"
        for msg in mailbox.fetch():
            temp = (msg.date, msg.subject, msg.html) 

    return HttpResponse(temp)
Sneha Makwana
  • 53
  • 1
  • 4

1 Answers1

0

https://github.com/ikvk/imap_tools/blob/master/examples/search.py

mailbox.fetch(AND(flagged=True))

(A long time ago in a galaxy far far away) star looked like a flag.

Vladimir
  • 6,162
  • 2
  • 32
  • 36