Outlook COM: how to create a MailItem from a .msg file

Guy Lateur guy.lateur at b-b.be
Tue Jul 5 05:33:22 EDT 2005


Thanks for the suggestion, Tim. Unfortunately, I get a 'connection refused' 
error on the line 'M = imaplib.IMAP4(server)'. It says "socket.error: 
(10061, 'Connection refused')". I've tried both the external IP adress and 
the internal one (10.0.0.2). I'm sure there's a way to get over this, isn't 
there?

One more question: can I avoid having (plain text) passwords in my code? I 
guess I could make a special account for this with a password known by 
everybody.

Cheers,
g




"Tim Williams (gmail)" <tdwdotnet at gmail.com> schreef in bericht 
news:mailman.1326.1120495311.10512.python-list at python.org...

Lateral thinking ?

=== untested ===

import imaplib, time, sys

f = open(msg_file)
r = f.readlines()
f.close()
msg1 = ''.join(r)
server = 'my.exchangeserver.com' # or IP address

user = 'user'
pw = 'pw'

M = imaplib.IMAP4(server)
M.sock.settimeout(120)
M.login(user,pw)[1][0]
M.select()
M.append('INBOX',None ,time.time() , msg1) # Inbox or other folder name
print "MESSAGE successfully saved"
#M.close()  Don't use close,  deletes/purges items
M.logout()[1][0] 





More information about the Python-list mailing list