Hi Dewey,
I think you can solve your problem when you write your assignments like this:
Set myOlApp = New Outlook.Application
Set MyItem = myOlApp.CreateItem(OlItemType.olMailItem)
Hope this helps
Christian
"Dewey" wrote:
> Please help! I am trying to send an email from within an Outlook COM addin,
> and I am getting a strange error:
>
> Unable to cast object of type 'System.__ComObject' to type
> 'Microsoft.Office.Interop.Outlook.ApplicationClass'.
>
> Here's the code I'm using:
>
> '-------------------------------
> Private Sub SendMail( )
>
>
> Dim myOlApp As Outlook._Application
> Dim MyItem As Outlook._MailItem
> myOlApp = New Outlook.Application
> MyItem = myOlApp.CreateItem(OlItemType.olMailItem)
> MyItem.Display( )
> On Error Resume Next
>
> MyItem.To = "me@hotmail.com" '<--(Changed)
>
>
> 'this is the body of the email
> MyItem.Subject = "test 1 2 3"
> MyItem.BodyFormat = Outlook.OlBodyFormat.olFormatHTML
>
>
> MyItem.Send()
>
> End Sub
> '-------------------------------
>
> Any help is greatly appreciated. Thank you!
> -Josh