如何使用预填充的附件打开Outlook的新邮件窗口 [英] How to open Outlook's new mail window with prepopulated attachment

查看:95
本文介绍了如何使用预填充的附件打开Outlook的新邮件窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

推荐答案

旧问题,但我也遇到了这个问题,因此这里有一个复制粘贴解决方案:

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

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

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

这篇关于如何使用预填充的附件打开Outlook的新邮件窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆