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

Tim Williams (gmail) tdwdotnet at gmail.com
Tue Jul 5 13:07:43 CEST 2005


On 7/5/05, Guy Lateur <guy.lateur at b-b.be> wrote:
> 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?

I just tried this and it failed with IP addresses but not
hostnames/machine names,  try it again with the server name. :)
  
> 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.

Depends how secure you need it to be.    For my simple stuff I just do
something like this

In idle/pythonwin/interactive

>>> p = 'password_string'
>>> p = p.encode("utf16")
>>> p
'\xff\xfep\x00a\x00s\x00s\x00w\x00o\x00r\x00d\x00_\x00s\x00t\x00r\x00i\x00n\x00g\x00'

Then in the script
user = mylogin
pw = '\xff\xfep\x00a\x00s\x00s\x00w\x00o\x00r\x00d\x00_\x00s\x00t\x00r\x00i\x00n\x00g\x00'
M = imaplib.IMAP4(server)
M.login(mylogin,pw.decode("utf16")
('OK', ['LOGIN completed.'])

HTH :)



More information about the Python-list mailing list