C# MailTo with Attachment?

If you want to access the default email client then you can use MAPI32.dll (works on Windows OS only).
Take a look at the following wrapper:

http://www.codeproject.com/KB/IP/SendFileToNET.aspx

Code looks like this:

MAPI mapi = new MAPI();
mapi.AddAttachment("c:\\temp\\file1.txt");
mapi.AddAttachment("c:\\temp\\file2.txt");
mapi.AddRecipientTo("[email protected]");
mapi.AddRecipientTo("[email protected]");
mapi.SendMailPopup("testing", "body text");

// Or if you want try and do a direct send without displaying the mail dialog
// mapi.SendMailDirect("testing", "body text");

Leave a Comment