![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi, Up until two weeks ago, I was quite happily using the sendobject function to send a message (I am using Office 2010 professional). However, all of a sudden I am getting an "Error 2295 unknown recipients" message. Trolling through a heap of info, as I understand it a security option has changed somewhere, so for me to continue I need to instigte outllok as an application when I click the command button. If I can continue with the sendobject, I would pefer it, but I do need to extend my knowledge ;-) Have to admit, I am a bit lost. I found a few snipets of info with the similar code, so I created the following. However, I keep on getting a "Error 13 Type Mismatch" error but cannot find out what I have done wrong. Any suggestions would be great. The code keeps on failing on the Set objmail = objOutlookApp.CreateItem(olMailItem) line. Private Sub testsend_Click() On Error GoTo cmdContinue_Err Dim objOutlookApp As Outlook.Application Dim objNameSpace As Outlook.NameSpace Dim objmail As Outlook.MailItem 'Set the application objects Set objOutlookApp = Outlook.Application Set objNameSpace = objOutlookApp.GetNamespace("MAPI") 'Login to Outlook objNameSpace.Logon 'Set the mail item Set objmail = objOutlookApp.CreateItem(olMailItem) 'Set properties for the mail item and send mail With objmail .To = "peter.morris (AT) whoopydoo (DOT) com" .Subject = "Message Sent from Visual Basic" .Body = "This message was created by automating Outlook from VB!" '.Send End With 'Logoff NameSpace objNameSpace.Logoff 'Release objects Set objmail = Nothing Set objNameSpace = Nothing Set objOutlookApp = Nothing cmdContinue_Exit: Exit Sub cmdContinue_Err: Select Case Err Case Else MsgBox "Error " & Err.Number & " " & Err.Description End Select Resume cmdContinue_Exit End Sub |
#3
| |||
| |||
|
|
Have to admit, I am a bit lost. I found a few snipets of info with the similar code, so I created the following. *However, I keep on getting a "Error 13 Type Mismatch" error but cannot find out what I have done wrong. *Any suggestions would be great. *The code keeps on failing on the Set objmail = objOutlookApp.CreateItem(olMailItem) line. |
#4
| |||
| |||
|
|
Have to admit, I am a bit lost. I found a few snipets of info with the similar code, so I created the following. *However, I keep on getting a "Error 13 Type Mismatch" error but cannot find out what I have done wrong. *Any suggestions would be great. *The code keeps on failing on the Set objmail = objOutlookApp.CreateItem(olMailItem) line. Hi Peter, Did you declare olMailItem with the right Type? Imb. |
#5
| |||
| |||
|
#6
| |||
| |||
|
|
Hi Peter I just used your code in one of my forms at it worked like a charm. I am using 2K7 and although I had to check a few libraries, once I did, she flew through to Outlook. Note the change I made to your code for ( .TO ) as I directly referenced the control field where my email addresses are stored. Also, just to help clarify which libraries I am using for Outlook. OLE Automation MSO Outlook View Control MSO Outlook 12.0 Object Library Private Sub cmdEmailAcc_Click() * * Dim objOutlookApp As Outlook.Application * * Dim objNameSpace As Outlook.NameSpace * * Dim objmail As Outlook.MailItem * * * 'Set the application objects * * * Set objOutlookApp = Outlook.Application * * * Set objNameSpace = objOutlookApp.GetNamespace("MAPI") * * * 'Login to Outlook * * * objNameSpace.Logon * * * 'Set the mail item * * * Set objmail = objOutlookApp.CreateItem(olMailItem) * * * 'Set properties for the mail item and send mail * * * With objmail * * * * * * *.To = Me.txtTradAccEm * * * * * * *.Subject = "" * * * * * * *.Body = "" * * * * * * *.Display * * * End With * * * 'Logoff NameSpace * * * 'objNameSpace.Logoff * * * 'Release objects * * * Set objmail = Nothing * * * Set objNameSpace = Nothing * * * Set objOutlookApp = Nothing cmdContinue_Exit: * * Exit Sub cmdContinue_Err: * * Select Case Err * * Case Else * * * * * *MsgBox "Error " & Err.Number & " " & Err.Description * * End Select * * Resume cmdContinue_Exit End Sub HTH Mick |
![]() |
| Thread Tools | |
| Display Modes | |
| |