Rudolph Scott

Hi. I'm trying to write code to do this. I am using Visual Studio 2005 and have Visual Studio Tools for Microsoft Office SE installed. I created a new project using the Outlook addin for Office 2007 and used the following code which I got from MSDN help;

Private Sub CreateMailItem()

Dim mailItem As Outlook.MailItem = _

Me.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem)

mailItem.Subject = "This is the subject"

mailItem.To = "Rudolph.Scott@iop.kcl.ac.uk"

mailItem.Body = "This is the message."

mailItem.Importance = Outlook.OlImportance.olImportanceLow

mailItem.Display(False)

End Sub

The problem is it keeps saying that CreateItem is not a member of the project. I originally had this code working with Outlook 2003 and it worked fine. Can someone tell me where I am going wrong and provide a solution Thanks.



Re: Visual Studio Tools for Office Creating Emails with Visual Studio 2005 and Outlook 2007

Sue Mosher - Outlook MVP

Try Me.Application.CreateItem or Globals.ThisAddIn.Application.CreateItem.



Re: Visual Studio Tools for Office Creating Emails with Visual Studio 2005 and Outlook 2007

Rudolph Scott

I saw your reply. Either of the two lines are ok, thanks. But now another problem! When I run the same project I get a 'System.Runtime.InteropServices.COMException' occurred error in MyApp.DLL, error code 0x80004005. I searched Google but could not find anything useful on it. Do you or anybody else know why I'm getting this message and how I can get around it Thanks in advance.



Re: Visual Studio Tools for Office Creating Emails with Visual Studio 2005 and Outlook 2007

Rudolph Scott

I have managed to get around the runtim error now.