The mapis Page

March 13th, 2013

Ever wondered how difficult it is to send email from a script, if the company you work for is locked into the prison guarded by Windows, Exchange and Outlook?

It’s all right to have a nice script for a software-release process, but what about notifying the interested parties about the release automatically?

Your first shot may be a Visual Basic script. It can create an Outlook email object and write its various fields. There is a small problem though. Outlook is a paranoid little bastard, and asks for your permission for the program to change the email’s fields. And asks it using a dialog-box.

But the casual observer may notice that some programs can pop-up pre-filled Outlook email windows like a breeze. 7-Zip springs to the lips. Right-click something, select `Compress to “foo.7z” and email’, and there pops up the email window with the attachment. No questions asked.

There is actually a very good reason why it’s 7-Zip that springs to the lips. Because it’s FOSS. Free and Open-Source Software. Step forward Igor Pavlov. I don’t want to go into details why, besides being FOSS, 7-Zip is the best archiving program ever, I’d just like to mention the facts that it has a command line interface, an mc-like two-pane GUI, Windows context menu-integration, and the best compression performance.

So I ended up downloading the source, and after a bit of searching I had the solution. Use the interface provided by “mapi.h”. Later I found out that there is a similar program called MAPIsend.exe in the MS BackOffice Resource Kit. A relaxed Hacker might wonder how Redmond invents these names. Anyway, `mapis’ ended up with having nearly identical calling parameters as MAPIsend.

The download package includes sources and the native Win32 binary. Compiled on Linux! Did I mention 7-Zip? It can unpack 7z archives.

Download mapis.7z


Save downloaded archive in a new folder called mapis
Unpack archive `7z x  mapis.7z’
Open a cygwin bash window in this folder
Type `make install’
See `man mapis’ or `mapis -h’ for usage

If you don’t have cygwin, get cygwin immediately, but until then just copy the `bin/mapis.exe’  file into a folder which is in PATH, e.g. c:\WINDOWS

Send a simple email to Master Foo, but first check everything in an email window:

mapis -r "Master Foo" -s "The Foo Subject" -m "The Foo message body."

Send another email straight away to Master Foo, copy to the Master Programmer, attach “c:\foo.c” and take the slightly longer message body from file “foomessage.txt”. Oh, and the MCSE shall receive a secret copy, just to scare him with the capabilities of Linux/gcc/mingw32.

mapis -q -r "Master Foo" -c "Master Programmer" -b MCSE \
      -s "foo source" -f c:\foo.c -t foomessage.txt


  1. No comments yet.
Comments are closed.