Python Forum
Trying to query e-mail server
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Trying to query e-mail server
#1
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'")
Reply
#2
Hmm surely someone has an answer even if it's not the correct answer.
I'm stil scratching my head....
Reply
#3
Ok well 133 views and not a single responce. Must be a record. Thanks for looking I guess. <solved>
Reply
#4
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?
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Paramiko Server -- Exception (server): Error reading SSH protocol banner ujlain 3 4,277 Jul-24-2023, 06:52 AM
Last Post: Gribouillis
  mail.message parse klaarnou 0 2,031 Oct-21-2018, 06:54 PM
Last Post: klaarnou

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020