![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
![]()
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 = " '--(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 |
#2
|
|||
|
|||
![]()
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 = " '--(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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Someone sending mail from my outlook | Vic Spainhower | Outlook - General Queries | 11 | May 15th 07 10:33 PM |
Outlook Freezes when sending mail | william | Outlook - General Queries | 0 | December 21st 06 03:21 PM |
Sending from Word with Outlook COM Addin | james | Add-ins for Outlook | 0 | May 30th 06 03:44 PM |
Sending mail with attachment from my vb6 addin | [email protected] | Add-ins for Outlook | 1 | April 27th 06 09:03 AM |
Addin HELP - Preview Pane, where is the mail event? | Joey | Outlook - Using Forms | 0 | March 17th 06 01:29 AM |