从WPF应用程序打开Outlook

时间:2014-09-30 06:13:41

标签: c# wpf outlook

我想要做的是当用户点击它打开outlook应用程序的标签时我有一个标签和MouseLeftButtonDown事件但是每当再次点击它就会遇到异常 这是我的代码`

if (e.LeftButton == MouseButtonState.Pressed)
{
    Microsoft.Office.Interop.Outlook.Application objOutlook = new Microsoft.Office.Interop.Outlook.Application();
    Microsoft.Office.Interop.Outlook.MailItem mic = objOutlook.CreateItem (Microsoft.Office.Interop.Outlook.OlItemType.olMailItem) as Microsoft.Office.Interop.Outlook.MailItem;
    mic.To = "someone@live.com";
    mic.Subject = "l";
    mic.Body = "h";
    mic.Display(true);
}

这是我得到的例外![Com Exception] [1]

[1]:

1 个答案:

答案 0 :(得分:2)

那个怎么样

var url = "mailto:foo@bar.com?subject=Test&body=Hello";
System.Diagnostics.Process.Start(url);