Python Forum
Trying to query e-mail server - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Networking (https://python-forum.io/forum-12.html)
+--- Thread: Trying to query e-mail server (/thread-20971.html)



Trying to query e-mail server - b4iknew - Sep-08-2019

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'")



RE: Trying to query e-mail server - b4iknew - Sep-11-2019

Hmm surely someone has an answer even if it's not the correct answer.
I'm stil scratching my head....


RE: Trying to query e-mail server - b4iknew - Sep-12-2019

Ok well 133 views and not a single responce. Must be a record. Thanks for looking I guess. <solved>


RE: Trying to query e-mail server - buran - Sep-12-2019

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?