How to open Outlook's new mail window with prepopulated attachment

Selvakumar picture Selvakumar · Sep 11, 2012 · Viewed 17.1k times · Source

I need to open a new email window with a prepopulated attachment when a user clicks some button or link in my application.

Answer

Pieterjan Spoelders picture Pieterjan Spoelders · Nov 4, 2015

Old question, but I also ran in to this so here's a copy and paste solution:

Microsoft.Office.Interop.Outlook.Application oApp = new Microsoft.Office.Interop.Outlook.Application();
Microsoft.Office.Interop.Outlook.MailItem oMsg = (Microsoft.Office.Interop.Outlook.MailItem)oApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);

oMsg.Subject = "subject something";
oMsg.BodyFormat = Microsoft.Office.Interop.Outlook.OlBodyFormat.olFormatHTML;
oMsg.HTMLBody = "text body"; //Here comes your body;
oMsg.Attachments.Add("c:/temp/test.txt", Microsoft.Office.Interop.Outlook.OlAttachmentType.olByValue, Type.Missing, Type.Missing);
oMsg.Display(false); //In order to display it in modal inspector change the argument to true

You'll need to add a reference to the Microsoft.Office.Interop.Outlook component in your project.