Skip to content

A .NET wrapper around Simple MAPI - a set of functions and related data structures to add messaging functionality to Windows-based apps

License

Notifications You must be signed in to change notification settings

IchbinkeinReh/Simple-MAPI.NET

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple-MAPI.NET

A .NET wrapper around Simple MAPI - a set of functions and related data structures to add messaging functionality to Windows-based apps

This project originated from the article Simple-MAPI-NET on CodeProject site

The nuget package

NuGet

PM> Install-Package Simple-MAPI.NET

What does it do?

Basically allows you to setup email messages using the default email client on the user's (Windows-based) machine.

Set a subject, body and attachments and simple (M)API invokes the default email client (eg Outlook/Windows Mail) with the message, ready to send.

History

I was using this source code within the ExceptionReporter.NET project.

It had been copied, with internal attribution, from the article on Simple-MAPI-NET from the Code Project site. But I noticed that no one else had committed this code a to a repository, so me to the rescue. And I wanted my ExceptionReport.NET library to use a dependency rather than horde all this unrelated code.

How to use

The console demo shows something slightly different, but I have used it, with success, like this (no logon/logoff)

using Win32Mapi;

.
var mapi = new Mapi();
mapi.AddRecipient(name: "[email protected]", addr: null, cc: false);
mapi.Attach(filepath: "c:\bob.txt")
mapi.Send(subject: "a subject", noteText: "a body text")

I don't use Logon/off() because at least in one case (64-bit Office/Outlook) it just creates a superflous error but sends anyway.

ie removing the call to Logon() still works.

Here's the initial issue writeup:

I'm trying to use ExceptionReporter in a managed Win32 Application.
I'm running on Win7/64, with 64-bit Office (including Outlook) installed and no 32-bit mail client (Win7 does not come with any mail client by default). When I try to get ER to send an Email, I see an error "Microsoft Office Outlook / Either there is no default mail client or the current mail client cannot fulfill the messaging request. Please run Microsoft Outlook and set it as the default mail client". It turns out that Outlook is the default mail client.
The message box is shown during the (first) call to MAPILogon in Mapi.Logon(), and the error value returned is 0x80004005; session is left at null. However, the code continues and sends the email successfully. Looking at the documentation for MAPILogon here: MAPILogon function it seems that the function is deprecated. I've disabled the call to mapi.Logon in MailSender.SendMapi and everything still seems to work fine. Since the call seems to be superfluous and troublesome, perhaps it would be better removed from the code?

About

A .NET wrapper around Simple MAPI - a set of functions and related data structures to add messaging functionality to Windows-based apps

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%