MAPI and managed code experiences?,
Using MAPI functions from within managed code is officially unsupported. Apparently, MAPI uses its own memory management and it crashes and burns within managed code (see and )
All I want to do is launch the default e-mail client with subject, body, AND one or more attachments.
So I’ve been looking into and it seems to work. But I haven’t been able to gather courage to actually use the function in production code.
Has anybody used this function a lot? Do you have any horror stories?
PS. No, I won’t shellExecute Outlook.exe with command line arguments for attachments.
PPS. Attachment support is a requirement , so Mailto: solutions do not cut it for me.
Have a separate helper EXE that takes command-line params (or pipe to its StandardInput) that does what is required and call that from your main app. This keeps the MAPI stuff outside of your main app’s process space. OK, you’re still mixing MAPI and .NET but in a very short-lived process. The assumption is that MAPI and the CLR start causing issues with longer-running processes.
We use Dmitry Streblechenko’s superb library which allows us to write such “shim” code in JScript and invoke that, which keeps the CLR and MAPI worlds in separate processes, but in a supported fashion.
@Chris Fournier re. writing an unmanaged DLL. This won’t work because the issue is mixing MAPI and managed code in the same process.
That’s the answer MAPI and managed code experiences?, Hope this helps those looking for an answer. Then we suggest to do a search for the next question and find the answer only on our site.
The answers provided above are only to be used to guide the learning process. The questions above are open-ended questions, meaning that many answers are not fixed as above. I hope this article can be useful, Thank you