如何使用预先填充的附件打开Outlook的新邮件窗口

Sel*_*mar 13 outlook office-interop outlook-addin outlook-2010 c#-4.0

当用户点击我的应用程序中的某个按钮或链接时,我需要打开一个带有预填充附件的新电子邮件窗口.

Pie*_*ers 23

老问题,但我也跑到这里,所以这里是一个复制和粘贴的解决方案:

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
Run Code Online (Sandbox Code Playgroud)

您需要Microsoft.Office.Interop.Outlook在项目中添加对组件的引用 .

  • 我认为这个答案应该标记为解决方案. (2认同)