At my work, I’m required to use Microsoft Outlook for exchanging email with my co-workers. At home, I use Mutt on FreeBSD, and have grown to really love the lightning-fast responsiveness, immunity to virusses, and easy scriptability of this tiny text-based mail reader.
I’m going to tell you one solution, just so I can tell you another one 🙂
It’s possible to use Mutt with Microsoft Exchange:
- Set up IMAP on your Exchange server. This was already done here.
- Install a copy of Cygwin, including Python.
- Either set up Mutt to access IMAP on Exchange directly, or do what I prefer to do: download and set up offlineimap. This IMAP-to-Maildir synchronization utility is excellent.
- First, you need to run the “rebaseall” utility so that Python doesn’t dump with traceback when you try to run offlineimap. You can’t rebaseall if you’re trying to do it from an rxvt window — you need to be using the cmd-based Cygwin shell for it to finish without an error.
- Then you need make sure your .offlineimaprc file specifies “Curses.Blinkenlights” as the first available interface — the TK interface, on Win32, just hangs.
- You can’t use offlineimap on a non-managed Cygwin mount. The reason is that the Maildir specification uses the “:” character, which is a big no-no in Windows-land. The solution is to use this command:
$ mount -f -s -b -o managed "d:/tmp/mail" "/home/of/mail"
substituting the windows-path directory you wish to use for mail for the “d:/tmp/mail” above, and the mount point you wish to put it on instead of “/home/of/mail”.
- Once you have IMAP-to-Maildir synchronization going to your local PC, then you’re good to go with offline IMAP stuff and Mutt. Follow the usual directions for configuring Mutt to use the Maildir you’ve set up, paying particular attention to choice of outbound mailer (probably ssmtp).
Obviously, though I’m a big fan of Mutt, that seemed like a lot of work. Lucky me, I chanced across a script that, with minor modifications, gave me the primary thing I loved about using Mutt: being able to use vim as my text editor. I’m just much faster using that than any other editor, and it’s ubiquitous on UNIX systems, either in a more-primitive incarnation of “vi”, or in some version.
So I installed Python and the Win32 extensions for Python, then linked this script on my quickbar in Windows, conveniently right next to Outlook:
#!/bin/env python ''' outlook.pyw (OutLook editor launcher) -- allows one to edit an open e-mail mesg from Outlook using Emacs or *Vi* rather than "Notepad--". :-) NOTE: requires Python 1.6 and newer (use of string methods)
created by John Klassa (klassa at employees.org) on 2001 May 29 updated by Wesley Chun (cyberweb at rocketmail.com) on 2002 Feb 28
$Id: outlook.pyw,v 0.2 2002/08/28 18:04:06 wesc Exp wesc $ '''
from os import spawnv, P_WAIT, unlink from tempfile import mktemp from Tkinter import Tk, Button, Frame, Label from Tkconstants import * from win32com.client import Dispatch
def launch(): '''launch() spawns your favorite editor to edit the Outlook compose window (either new or reply), then returns that data to Outlook... change the 'ed' variable to switch editors.'''
# Get a handle to Outlook. o = Dispatch("Outlook.Application")
# Work our way down to the reply (a "MailItem"). insp = o.ActiveInspector() if insp == None: return item = insp.CurrentItem if item == None: return
# Grab the message body in the reply. body = item.Body
# Write the body... need to "encode" the string because Outlook uses # Unicode with bunch of unprintables (ASCII chars > 128). Also, since # we are going from DOS2UNIX2DOS, we have the \r\n vs \n issue, re- # sulting in those fabulous ^M characters. A persistent, bound-to-a- # key Emacs macro takes care of that nicely, but the solution imple- # mented here is to just wipe the '\r's now, then add them back when # we reread this file back before returning the body to Outlook. tmp = mktemp() # generate a unique tmp filename fh = open(tmp, "w") fh.write(body.encode('ascii', 'ignore').replace('\r\n', '\n')) fh.close()
# Launch editor to edit the file (should make this configurable). #ed = r"d:\emacs-20.7\bin\emacs" # emacs editor binary ed = r"c:\vim\vim62\gvim.exe" # *vi* editor binary spawnv(P_WAIT, ed, [ed, tmp])
# Read edited file back into memory, restore '\r's, and kill tmp file. fh = open(tmp) body = fh.read().replace('\n', '\r\n') fh.close() unlink(tmp)
# Store it as the body of the reply. Note that we are merely # sending this data back to Outlook -- it does not prevent MS from # mucking with your message. For example, it may add your signature # again, or it may remove newlines. MS software... what can you do? item.Body = body
# Create the Tk(inter) GUI app with the appropriate label and buttons. if __name__=='__main__': tk = Tk() f = Frame(tk, relief=RIDGE, borderwidth=2).pack() Label(f, text="Outlook Edit Launcher v0.2").pack() Button(f, text="Edit", fg='blue', command=launch).pack(fill=BOTH) Button(f, text="Quit", fg='red', command=tk.quit).pack(fill=BOTH) tk.mainloop()
I now click Outlook, then click my outlook.py script. I minimize the annoying black cmd window that comes up (anybody know how to get rid of this?), and I now have a little Python/TK window with a convenient “edit” button on it. When I compose a message in LookOut, I click this “edit” button, and up pops gvim 6.2, ready for me to type the message. When I’m done typing it, I just write-quit out of gvim, and the text pops up in my Outlook compose window.
Convenient! Well, for a UNIX-geek at least.
Anyway, I’m still torn. Do I really need to use Outlook here? Realistically, I have maybe one meeting a week that I need to keep track of, and that’s easily done in my Palm. Maybe I should just use Mutt in Cygwin on a managed mount? Who knows, but both are valid choices. And in a world where MS wants you to only use MS products, and those products are funkily generic and slow, it’s nice to have choices.
We’ve heard cases before where an expectant mother has been putting her fetus at risk by drinking, or using drugs, or other dangerous behavior. This one has a different twist– it wasn’t what she was doing, it was what she didn’t do.