How to send a mail using MAPI?

Lundin picture Lundin · Oct 17, 2011 · Viewed 15.7k times · Source

I want to send an e-mail using the mail client on the user's Windows computer. As far as I can tell from the net, MAPI is the way to go. However, after reading through the MSDN documentation, I find out that MAPI is quite vast, with no source code examples. And I have no need for 99% of the features, I just want to send an e-mail. How do I do this?

I have found examples here on SO and on the web, but they seem to rely on something called Simple MAPI, which Microsoft has apparently listed as obsolete: "The use of Simple MAPI is discouraged. It may be altered or unavailable in subsequent versions of Windows". So I don't want to use those functions.

I found a very good example here, but unfortunately it is for Windows CE and isn't fully compatible with the Win32 API. I managed to implement the code from that link until it got to where it attempts to open the drafts folder, the parameters to GetProps aren't compatible. Does anyone know where I can find a similar code example for PC? C++ prefered.

Answer

Lundin picture Lundin · Oct 24, 2011

I have solved this by my own, with the help from various internet sources.

Official MSDN documentation

MAPIEx: Extended MAPI Wrapper

Once the code is properly tested & documented, I will try to post it here for future reference.