简体   繁体   中英

Open Outlook from WPF Application

what I am trying to do is I have a label and MouseLeftButtonDown Event on it when the user click on the label it open the outlook application but whenever click again it run into an Exception here is the code that I have `

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);
}

and here is the Exception that I got ![Com Exception][1]

[1]:

How about that

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM