Python Forum

Full Version: Trying to query e-mail server
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,
I'm fairly new to python and still learning. I wrote what I thought was a simple script trying to query my email server for NEW eamil. My problem is, the code runs without any error's.
Logs into server just fine but it never returns resulting in NEW mail even when there is in fact NEW mail on the server. What am I missing to have it return a value for NEW mail? Using Python 3.7 on Windows 10.
Any help would be greatly appreciated. Thanks in advance!

import imaplib
from os import *
import subprocess

email_server = "mail.mymail.net" # mymail = imap.mymail.net
user = "[email protected]"
password = "passwd"
notification_title = "New Mail"

server = imaplib.IMAP4_SSL(email_server)
server.login(user, password)
server.select("INBOX")

x, items = server.search(None, "UNSEEN")
count = 0
for num in items[0].split():
    server.status(num, '(RFC822)')
    count += 1

if count > 0:
	subprocess.Popen("schtasks.exe /run /tn 'MailReport'")
Hmm surely someone has an answer even if it's not the correct answer.
I'm stil scratching my head....
Ok well 133 views and not a single responce. Must be a record. Thanks for looking I guess. <solved>
You may want to share what the problem and solution was...
There is no need to be frustrated. What's the point to post useless answer if one cannot provide assitance or at least direction?