dbTalk Databases Forums  

outlook.application error

comp.databases.ms-access comp.databases.ms-access


Discuss outlook.application error in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Peter Morris
 
Posts: n/a

Default outlook.application error - 09-29-2011 , 02:15 AM






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

Reply With Quote
  #2  
Old   
Phil
 
Posts: n/a

Default Re: outlook.application error - 09-29-2011 , 03:54 AM






On 29/09/2011 08:15:12, Peter Morris wrote:
Quote:
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


It's only a guess, but outlook may not have opened properly.

I use

Dim FlgQuit As Boolean

On Error Resume Next
Set OLApp = GetObject(, "Outlook.Application")
If Err.Number = 0 Then
FlgQuit = False
Else
Set OLApp = CreateObject("Outlook.Application")
Call Call apWait(1.5, False) ' Wait 1.f seconds to allow things to happen
If OLApp.Session.Offline = True Then
FlgQuit = True
End If
End If
On Error GoTo 0
Err.Clear

Phil

Reply With Quote
  #3  
Old   
imb
 
Posts: n/a

Default Re: outlook.application error - 09-29-2011 , 05:45 AM



Quote:
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.

Reply With Quote
  #4  
Old   
Peter Morris
 
Posts: n/a

Default Re: outlook.application error - 10-05-2011 , 12:07 AM



On Sep 29, 8:45*pm, imb <im... (AT) onsmail (DOT) nl> wrote:
Quote:
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.
Hi,

Sorry, only just got back to this. The only declarations etc I have
made are as indicated in the code I popped in. I did not determine
anything else was needed from the code blocks I was looking at. Have
I missed something? The odd thing is the orginal code is working like
a treat on those PC's running Access 2010 Runtime.

Peter.

Reply With Quote
  #5  
Old   
Vacuum Sealed
 
Posts: n/a

Default Re: outlook.application error - 10-08-2011 , 12:11 PM



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

Reply With Quote
  #6  
Old   
Peter Morris
 
Posts: n/a

Default Re: outlook.application error - 10-16-2011 , 01:42 AM



On Oct 9, 3:11*am, "Vacuum Sealed" <noodn... (AT) gmail (DOT) com> wrote:
Quote:
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
Hi Mick,

Cool. I'm am very happy the code actually works. I however, and
still tearing out what little hair I have left as I cannot get it work
on any pc with Office 2010. Still does not matter if I am running
office on XP either.

Oh well, I'll keep plugging away at it, thought the boss is getting a
bit snotty.

Stinky Pete.

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.