Created
October 16, 2013 17:47
-
-
Save dloman/7011907 to your computer and use it in GitHub Desktop.
Python script for getting number of new messages on an exchange server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
##Gets Number of New Emails | |
##Daniel Loman 10/15/2013 | |
import getpass, imaplib, pickle | |
######################################################################################## | |
######################################################################################## | |
def GetNumberOfMessages(): | |
Mailbox = imaplib.IMAP4("server.address") | |
AuthenticationToken = pickle.load(open(AuthFileLocation,'rb')) | |
Mailbox.authenticate("NTLM", AuthenticationToken) | |
Mailbox.select(readonly=True) | |
Typ, MessageNums = Mailbox.search(None,'UNSEEN') | |
if '' in MessageNums: | |
MessageNums.remove('') | |
return len(MessageNums) | |
######################################################################################## | |
######################################################################################## | |
if __name__ == "__main__": | |
print 'Number Of New Messages =',GetNumberOfMessages() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment