-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdraft_counter.py
38 lines (27 loc) · 1.13 KB
/
draft_counter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# ---------------------------------------------------------------------------------------------------------------------#
# draft_counter.py
#
# This module counts the number of orders in the Drafts folder.
#
# ---------------------------------------------------------------------------------------------------------------------#
import win32com.client
from configparser import ConfigParser
from pathlib import Path
from time import sleep
def main():
config_path = Path(__file__).parent.absolute().joinpath('config.ini')
config = ConfigParser()
config.read(config_path)
primary_mailbox = str(config['Outbot Options']['primary_mailbox'])
outlook = win32com.client.Dispatch('Outlook.Application')
mapi = outlook.GetNamespace('MAPI')
draftbox = mapi.Folders[primary_mailbox].Folders['Drafts']
count = 0
messages = draftbox.Items
messages.Sort("[ReceivedTime]", Descending=False)
for item in messages:
message_name = item.Subject
if 'FILM' not in message_name and 'RDX' not in message_name:
count += 1
print(count, 'draft orders!')
main()