<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <title>andthennothing.net: Outlook of no return</title>
  <subtitle type="html">&amp;ldquo;first there was a three-legged monkey...&amp;rdquo;</subtitle>
  <id>tag:andthennothing.net,2005:Typo</id>
  <generator uri="http://typo.leetsoft.com" version="4.0">Typo</generator>
  <link href="http://andthennothing.net/xml/atom10/article/201/feed.xml" rel="self" type="application/xml+atom"/>
  <link href="http://andthennothing.net/archives/2002/11/22/outlook-of-no-return" rel="alternate" type="text/html"/>
  <updated>2005-12-18T03:19:06+00:00</updated>
  <entry>
    <author>
      <name>Jonas Bengtsson</name>
      <email>jonas.b@home.se</email>
    </author>
    <id>urn:uuid:2be7e2cc-c648-4e26-b302-e3c81b30570c</id>
    <published>2002-11-22T03:04:41+00:00</published>
    <updated>2005-12-18T03:19:06+00:00</updated>
    <title>Outlook of no return</title>
    <link href="http://andthennothing.net/archives/2002/11/22/outlook-of-no-return" rel="alternate" type="text/html"/>
    <content type="html">&lt;p&gt;Yesterday I got a crazy idea that I wanted to migrate some mail for mailinglists from Outlook to a mail application I use for mailinglists. It turned out to be easier said than done.&lt;br /&gt;&lt;br /&gt;First I tried to save a mail in Outlook, but I could only save it as text (in Swedish and did just include subject, from, to, date (also in Swedish), and body), or as binary files. Hurray!&lt;br /&gt;&lt;br /&gt;Then I tried to export a folder of messages to a comma separated file. I tinkered a bit with &lt;a href="http://www.ruby-lang.org/"&gt;Ruby&lt;/a&gt;, got the &lt;a href="http://www.ruby-lang.org/en/raa-list.rhtml?name=csv"&gt;csv library&lt;/a&gt; to parse the file and was able to create one file per mail. But, I later found out that the exported file from Outlook did &amp;#8220;just&amp;#8221; include subject, body, from name, from address, from type (e.g. &amp;#8220;SMTP&amp;#8221;), to name, to address, to type, cc name, cc address, cc type, bcc name, bcc address, bcc type, billing information, sensitivity, categories, priority, travel allowance (km). That is a lot of information! But not anything about when it was sent, the id of the mail, the headers, and a lot of other interesting stuff. Hence, comma separated files were a dead end. Sigh!&lt;br /&gt;&lt;br /&gt;Somehow I thought that I would get what I wanted by using &lt;span class="caps"&gt;COM&lt;/span&gt; and accessing Outlook directly. It must be possible since there are several synchronization applications for example Palm. But I had almost no clue about how to use &lt;span class="caps"&gt;COM &lt;/span&gt;(the only time I&amp;#8217;ve messed with it before was &lt;a href="http://hem.passagen.se/zanoi/blog/2002_06_01_archive.html#77806570"&gt;a couple of months ago&lt;/a&gt; in Java). So I turned to &lt;a href="http://www.python.org/"&gt;Python&lt;/a&gt;. After a lot of tinkering I managed to access the different mails in Outlook and read some of the information (it was not completely trivial). So I started by printing stuff like date, from, to, subject, and body. But, of course, the date was not a valid &lt;a href="http://www.faqs.org/rfcs/rfc822.html"&gt;rfc822&lt;/a&gt; date. And apparently is strptime() only available on some versions of Unix, but the &lt;a href="http://aspn.activestate.com/ASPN/Python/Cookbook/"&gt;Python Cookbook&lt;/a&gt; came to the rescue with a &lt;a href="http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/56036"&gt;pure Python version of strptime()&lt;/a&gt;. So now I could parse the date and create a rfc822 compatible date.&lt;br /&gt;&lt;br /&gt;But then I got greedy. By using Outlook I can read the headers, why should I not be able to do that in Python? So I googled around for some time and eventually I found &lt;a href="http://www.outlookexchange.com/articles/home/mailitem.asp"&gt;an object model of the MailItem Outlook Object&lt;/a&gt;. But the headers are nowhere to find! But then I found the &lt;a href="http://www.dimastr.com/outspy/"&gt;OutlookSpy&lt;/a&gt; which is an Outlook plugin that you can use to browse the objects in Outlook. There it was! My search seemed to be over: the property with the tag PR_TRANSPORT_MESSAGE_HEADERS. But how do you access that? After some time of trial and error I posted a question to comp.lang.python. I got a pointer to &lt;a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/spambayes/spambayes/Outlook2000/msgstore.py"&gt;msgstore.py&lt;/a&gt; in the &lt;a href="http://spambayes.sourceforge.net/"&gt;SpamBayes&lt;/a&gt; project. But the code was a little bit hard to understand.&lt;br /&gt;&lt;br /&gt;I had given up at this point. But as I was writing the above I decided to take a look at the script again and noticed the test at the bottom. That didn&amp;#8217;t look too tricky. And after a while I managed to use it to get both headers and body of a mail. Success! Now I have exported all the 487 messages to individual files, and then imported the messages into the other mail application. Now I can sleep with a smile on my face! :&lt;del&gt;)  Good night!&lt;br /&gt;&lt;br /&gt;&lt;i&gt;ps. What are they (Microsoft) thinking? Why do they lock their users? Why aren&amp;#8217;t they embracing open standards? When will I be trusted with my own data? Why, oh, why? Perhaps I should get that sleep now :&lt;/del&gt;) ds.&lt;/i&gt;&lt;/p&gt;</content>
  </entry>
</feed>
