【发布时间】:2014-03-05 09:41:21
【问题描述】:
我只想打开 Outlook 的“新电子邮件”窗口并填充多个附件,我认为 Process.Start 会比 SMTP 更容易,因为我不必传入我的 SMTP 服务器。我最初的计划是使用Microsoft.Office.Interop.Outlook,但由于我以管理员身份运行我的应用程序,我不得不排除这个选项。
这是我目前所拥有的,它只需要一个附件,我可以在 fn 之后传入第二个参数(fn2)吗?
static void Main(string[] args)
{
string programFilesPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
var selectedApplicationPath = Directory.GetFiles(programFilesPath, "Outlook.exe", SearchOption.AllDirectories);
if (selectedApplicationPath.Length <= 0) return;
var outlookProcessPath = selectedApplicationPath[0];
if (string.IsNullOrWhiteSpace(outlookProcessPath)) return;
string fn = @"path1";
string fn2 = @"path2";
Process.Start(outlookProcessPath, "/a \"" + fn + "\"");
}
【问题讨论】:
-
为什么你不能使用 Outlook Interop?
-
很难解释;就像当您以管理员身份启动应用程序时,Outlook 会假定该用户已经是用户。因此,outlook 不允许您拥有第二个用户。
标签: c# email outlook email-attachments process.start