Dexter90
Dexter90

Reputation: 69

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 = "[email protected]";
    mic.Subject = "l";
    mic.Body = "h";
    mic.Display(true);
}

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

[1]:

Upvotes: 1

Views: 2996

Answers (1)

coder0815
coder0815

Reputation: 229

How about that

var url = "mailto:[email protected]?subject=Test&body=Hello";
System.Diagnostics.Process.Start(url);

Upvotes: 3

Related Questions