[python-win32] Outlook COM: how to create a MailItem from a .msg file

Guy Lateur guy.lateur at b-b.be
Fri Jul 8 15:41:45 CEST 2005


Yes! I finally got it to work. I've written a VBscript which I'll call
from 
python. It uses Outlook.Redemption's SafeMailItem. No need to use IMAP
or 
whatever services.

Only weird thing is it doesn't put the msg in the Inbox, as I intended,
but 
in the Drafts folder. Well, never mind that, it's a temp object anyway.

Here's the code:

Dim sItem, oItem
Dim myDestBox, myNS, myOL

Set myOL = CreateObject("Outlook.Application")
Set myNS = myOL.GetNamespace("MAPI")
Set sItem = CreateObject("Redemption.SafeMailItem")

Set myDestBox = myNS.GetDefaultFolder(6)
Set oItem = myDestBox.Items.Add(0)

sItem.Item = oItem
sItem.Import 
"H:\Inhoud-iedereen\Inhoud-Guy\app\BBProject\data\test\Leemarchitect.msg
", 3
sItem.Save



Cheers,
g



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-win32/attachments/20050708/9c8321fd/attachment.htm


More information about the Python-win32 mailing list