forked from O365/python-o365
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfetchFile.py
More file actions
52 lines (35 loc) · 971 Bytes
/
fetchFile.py
File metadata and controls
52 lines (35 loc) · 971 Bytes
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from O365 import *
import json
import os
import sys
import time
import logging
logging.basicConfig(filename='ff.log',level=logging.DEBUG)
log = logging.getLogger('ff')
def processMessage(m):
path = m.json['BodyPreview']
path = path[:path.index('\n')]
if path[-1] == '\r':
path = path[:-1]
att = Attachment(path=path)
resp = Message(auth=auth)
resp.setRecipients(m.getSender())
resp.setSubject('Your file sir!')
resp.setBody(path)
resp.attachments.append(att)
resp.sendMessage()
return True
print "checking for emails"
with open('./ff.pw','r') as configFile:
config = configFile.read()
cjson = json.loads(config)
e = cjson ['email']
p = cjson ['password']
auth = (e,p)
i = Inbox( auth, getNow=False) #Email, Password, Delay fetching so I can change the filters.
i.setFilter("IsRead eq false & Subject eq 'Fetch File'")
i.getMessages()
log.debug("messages: {0}".format(len(i.messages)))
for m in i.messages:
processMessage(m)
#To the King!