Revision 5227,
569 bytes
checked in by brunocosta, 13 years ago
(diff) |
Ticket #2348 - Coloca controle de erros no python que faz o desarquivamento.
|
Line | |
---|
1 | import imaplib |
---|
2 | import sys |
---|
3 | import base64 |
---|
4 | |
---|
5 | host=sys.argv[1] |
---|
6 | port=int(sys.argv[2]) |
---|
7 | user=sys.argv[3] |
---|
8 | password=sys.argv[4] |
---|
9 | date_time=int(sys.argv[5]) |
---|
10 | mailbox=sys.argv[6] |
---|
11 | print sys.argv[7] |
---|
12 | imap_file = open(sys.argv[7],"r") |
---|
13 | tmp=imap_file.read() |
---|
14 | message=base64.b64decode(tmp) |
---|
15 | #print message |
---|
16 | imap_file.close() |
---|
17 | try: |
---|
18 | M = imaplib.IMAP4(host,port) |
---|
19 | M.login(user,password) |
---|
20 | flags="" |
---|
21 | M.append(mailbox,flags,date_time,message) |
---|
22 | #print mailbox+flags+date_time+message |
---|
23 | M.logout() |
---|
24 | #M.close() |
---|
25 | print "no errors" |
---|
26 | except imaplib.IMAP4.error, erro: |
---|
27 | print erro |
---|
Note: See
TracBrowser
for help on using the repository browser.