View Single Post
  #1  
Old July 18th 07, 01:16 AM posted to microsoft.public.outlook.program_addins
Dewey
external usenet poster
 
Posts: 26
Default Please help! Sending mail from a COM add-in

Please help!

I've been trying to send an email from within a COM addin in VB.net 2005,
but keep getting a very weird message:

'Unable to cast object of type 'System.__ComObject' to type
'Microsoft.Office.Interop.Outlook.ApplicationClass '.

I am trying to send from a form in a COM addin that I open from within
Outlook


Here's the sub I use:
-----------------------------
Private Sub SendMail( )

Dim myOlApp As Outlook._Application
'Dim myOlApp As Object
Dim MyItem As Outlook._MailItem
Dim luvRecipients As Outlook.Recipients
Dim luvRecipient As Outlook.Recipient
myOlApp = New Outlook.Application
'MyItem = myOlApp.CreateItem(OlItemType.olMailItem)
'MyItem.Display()
On Error Resume Next


'this is the body of the email
MyItem.Subject = "Image sending test"
MyItem.BodyFormat = Outlook.OlBodyFormat.olFormatHTML
MyItem.HTMLBody = "HTMLDIV ALIGN=CENTERIMG
src='\\Fil-nw04-10\hello.jpg/HTML"

MyItem.Send()

End Sub
-----------------------------

Thanks very much for any help in advance!

-Josh

Ads