Open outlook 2007 with c-sharp.net
The problem with some solution I found online is that a lot of them goes straight to the solution, they sometimes forget that there are pre-requisites before jumping into the code.
For 2007 outlook you to open up and pre populate the fields you need to include some things to make it work.
The first one is the Microsoft Office Outlook 12 library which can be found by adding a reference to your VS project under COM. Also you need to include it on your namespace such as “using Microsoft.Office.Interop.Outlook”
Then the code part, you can create a method such as this one.
protected void OpenOL(object sender, EventArgs e)
{
try
{
Application olApp = new Microsoft.Office.Interop.Outlook.Application();
MailItem outMailItem = (MailItem)(olApp.CreateItem(OlItemType.olMailItem));
Recipient oReceipt;
oReceipt = (Recipient)outMailItem.Recipients.Add(“emailadd@company.com”);
oReceipt.Resolve();
outMailItem.Subject = “This is the subject”;
outMailItem.Body = “This is a sample body”; // dataAdapater
outMailItem.BodyFormat = OlBodyFormat.olFormatHTML; // or plane text
outMailItem.Display(true);
oReceipt = null;
outMailItem = null;
olApp = null;
}
catch (System.Runtime.InteropServices.COMException)
{
}
One more thing to keep in mind, that this only runs if you have outlook installed on your computer (host or server) and to have outlook you must also have Microsoft office 2007.