2009/2/16 Paul Moore <p.f.mo...@gmail.com>: > 2009/2/16 Tim Golden <m...@timgolden.me.uk>: >> They're structured storage and a bit opaque. In principle >> this (very sketchy and untested) code should get you started: > > Thanks, that's a good start. Actually, your mention of the IStream > interface below reminds me, I'm fairly sure I saw somewhere a mention > of a CDO method to load a message from a stream, so that's probably > what I need (plus your code below). > > I'll go rummaging and see what I can find. Thanks!
For reference, what I came up with is import sys from win32com.client import Dispatch filename = sys.argv[1] stm = Dispatch("ADODB.Stream") stm.Open() stm.LoadFromFile(filename) msg = Dispatch("CDO.Message") msg.DataSource.OpenObject(stm, "_Stream") print repr(msg.From) print repr(msg.Subject) #print repr(msg.TextBody) which is essentially what gets recommended in various places on the web. Ironically, it's not using structured storage, but ADO streams, for whatever the difference implies. One minor problem - it doesn't work for me (:-)) I suspect this might be to do with subtle issues around the version of Outlook we use (2003) and whether I save the file as "Outlook Message Format" or "Outlook Message Format - Unicode". I say this, because these issues gave us compatibility problems a while ago, which we never tracked down but which "went away" somewhere in a series of patches/updates. So it may be I'm hitting an old CDO library, or something. Sigh. It's stuff like this that makes me end up doing stuff by hand whenever I try scripting Outlook :-( I'll report back on what (if anything) I find - if only for the archives. Paul. _______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32