I want to know if there is anyway I can make an email alert with a balloon popup in the system tray, so far starting with I have made a system tray icon using pyqt that seemed to be simple enough, but I am not finding any starting point for an email alert with specific keyword or to specific email id :-/

Sorry I don't have a solid example to back this up but I would start with either imaplib or poplib. Both allow you to login/authorize an email account and check for messages. From there it would be filtering addresses with either if 'my@email.com' in address.lower(), or a regex expression. I think the steps would be something like this:

Retrieval Stage for IMAP:

#1) Login using provided credentials
connection = imaplib.IMAP4('myemailhost.com', 143) # port 143 is default anyway
connection.login(USER, PASS)

#2) Retrieve messages
goodmsgs = connection.list("INBOX", "[optional regex to filter msgs]")

#3) Filter messages by email address
(may be able to do with while retrieving)

Retrieval Stage for POP3:

# 1) Login using provided credentials:
connection = poplib.POP3('pop.myhost.com', 110) # poprt 110 is default anyway
msgcount, msgsize = connection.pass_(PASSWORD)
# another way to get message count:
# msgcount, msgsize = connection.stat()

# 2) Retrieve messages
# retrieve a message (single message in this case)
serverresponse, msglines, octects = connection.retr(2)

... if the message is a new one, and is from the right email address, move on to the display stage.

Display Stage:
4) Show pop-up with email count/preview
5) Wait 15 minutes (or however long you want)
6) Repeat

...I haven't tested all of this, only part of it. But with these two libraries (there may be even better ones out there) you can do what you want. This is just what a quick PyPi search, and help('poplib'); help('imaplib') turned up. My point is, if you can get a list of messages, filtering them by any keyword will be easy.

Edited 3 Years Ago by chriswelborn

This article has been dead for over six months. Start a new discussion instead.