I have a winforms application and I am trying to create a method that will create and open a new Outlook Email. So far I have
private void CreateOutlookEmai
Think about it. You are calling the CreateItem
method on this
current object. Have you defined the CreateItem
method in this class?
Instead of your:
Outlook.MailItem mailItem = (Outlook.MailItem) this.CreateItem(Outlook.OlItemType.olMailItem);
You need the lines:
Outlook.Application outlookApp = new Outlook.Application();
Outlook.MailItem mailItem = (Outlook.MailItem) outlookApp.CreateItem(Outlook.OlItemType.olMailItem);
You create an instance of the outlook application, on which you can call the CreateItem
method.
There are two more things to make this work properly.
1) Add a reference to the Microsoft.Office.Interop.Outlook
package to your project
2) Ensure you have the appropriate using statement in your class
using Outlook = Microsoft.Office.Interop.Outlook;