How to build MAPI Editor with VS 2005

Photo by Lawrence Whittemore

MAPI Editor is a great open-source example of how to access data on an Exchange server. It took a little bit of tweaking to get it compiling on my Windows Server 2003 box with Visual Studio 2005, so here’s my directions:

Version Conversion. The project is still set up for Visual Studio 6, so you’ll need to convert it to work with VS 2005. You can normally just load the old .vcproj project file and have VS create a new project from it. Unfortunately this fails in this case, but an easy workaround is to load the .dsp workspace instead. The conversion works in that case.

Deprecation Frustration. Editor.cpp uses _tfopen(), but this is marked as deprecated in the latest Visual Studio C runtime library, because it has security issues. Again there was a fairly simple solution, replacing it with the new _tfopen_s function. Here’s the code change in MFCOutput.cpp: Line 84

Old:    fOut = _tfopen(szFileName,szParams);
New:    _tfopen_s(&fOut, szFileName,szParams);

Inclusion Confusion. Editor.cpp includes vssym32.h on line 13. This was introduced after Server 2003, but there’s an equivalent older header you can use. Here’s the changes:

Old:    #include <vssym32.h>
New:    #include <tmschema.h>

Installation Aberration. The project links to msi.lib. Unfortunately there’s a known bug with Visual Studio 2005 that means this isn’t installed in the default platform SDK that ships with the product, so the linking stage fails. The obvious solution is to install one of the separate platform SDKs that Microsoft offers. Whilst I was waiting on one of these to download, I experimented with removing it entirely from the project, and it looks like it’s actually no longer needed, since it still builds and runs fine. So, just go into the linker portion of the project settings and remove msi.lib from the input portion.

I’ve filed bugs to document these issues here, here, here and here. Fixing some of them could break backwards compatibility with older versions of the compiler, so making code changes might not make sense, but I wanted to get them documented.

2 responses

  1. The .vcproj that is included is set up for VC 2008. It’s actually a goal of mine to keep the codebase working in VC 6, 2005, and 2008, so these bugs are helpful. I’ll comment the issues individually as I investigate them.

  2. Doh, it looks like the existing .vcproj is for Visual Studio 2008 from your comments. Can I blame VS 2005 for still trying to convert the project as if it were from a previous version, and failing with a cryptic error message? That sounds like it also solved the msi.lib issue.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: