Question

I send an email to my Raspberry Pi GMail account for it to carry out tasks. Using Python it checks the GMail subject line and the recipient email address and if these are correct it carries out the appropriate task. I use feedparser to check the email account and the contents of the subject line (see below).

details = feedparser.parse("https://" + PiEmail + ":" + PiPwd + "@mail.google.com/gmail/feed/atom")
FromEmail = details['items'][i].author_detail.email
Subject = details['items'][i].title.lower()

However, once the task has been carried out how can I mark that specific email which contains the instruction as having been read?

No correct solution

OTHER TIPS

I guess it can't be done using Feedparser. I needed to do the same thing and I solved it using the imaplib library to change email's flag from "UNSEEN" to "SEEN" after checking the gmail subjects this way:

import imaplib

details = feedparser.parse("https://" + PiEmail + ":" + PiPwd + "@mail.google.com/gmail/feed/atom")
FromEmail = details['items'][i].author_detail.email
Subject = details['items'][i].title.lower()

obj = imaplib.IMAP4_SSL('imap.gmail.com', '993')
obj.login(PiEmail, PiPwd)
obj.select('Inbox')  
typ ,data = obj.search(None,'UnSeen')
obj.store(data[0].replace(' ',','),'+FLAGS','\Seen')

I hope it works for you!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top