Runtime Error 0x???04005

  • Thread starter Thread starter .Len B
  • Start date Start date
L

.Len B

I was referred here by Ken Slovak when I posted the question below
to the outlook.interop group. At Ken's suggestion I added a namespace
and performed a logon to it. That produced the same error description
but different error numbers. I am not familiar with the Outlook object
model but I guess I can expect that I'll need to be soon.

----------
I am trying to use MS Access 2003 to automate the sending of a number
of messages. I have the following code (stolen from MS KB161088 and
modified) which fails with error code -1594867707 (a0f04005) when
executing the .Send method. Googling the hex error gave zero results
and Googling the decimal error yielded runtime errors with differing
numbers, none of which were relevant.

Clicking on Help from the error dialog brings up help on error
440 - Automation.

The text of the error is: Outlook does not recognize one or more
names. Googling this yields a Microsoft support page suggesting
that the address book is corrupt. I can successfully send e-mail
directly from OL and the sole test recipient is my own email
address which does appear in my address book.

Dim objOut As Outlook.Application
Dim objOutMsg As Outlook.MailItem
Dim oNS as Outlook.NameSpace 'suggested by Ken Slovak
Dim strRecipient As String, strSubject As String
Dim strBody As String
Dim blnDisplayMsg As Boolean

blnDisplayMsg = Me.chkDisplay 'do we display the email first
Set objOut = CreateObject("Outlook.Application") 'Create Outlook session
Set oNS = objOut.GetNamespace("MAPI") 'suggested by Ken Slovak
oNS.Logon "","", False, False 'suggested by Ken Slovak
....
Set objOutMsg = objOut.CreateItem(olMailItem) 'create Outlook message
With objOutMsg
.recipients.Add strRecipient 'To field
.subject = strSubject 'Subject field
.body = strBody 'Body field
If blnDisplayMsg Then 'display before sending
.Display
Else 'just send it
.Save
===> .Send
End If
End With 'done with this message
'erase just sent msg from memory
Set objOutMsg = Nothing

If I send the logic through the .Display method instead, OL fires
and the fields are correctly populated. Clicking on the [Send]
button has the expected result. However, requiring the user to
click send on multiple messages somewhat defeats the purpose.

I hope I am asking in the right forum.
Where to from here?
----------
I am developing on OL2003 connected to POP3 at my ISP.
Target system is OL2003 with Exchange Server [SBS 2003].

I am running into the "object model guard" issue but Ken gave me
a link so that I can look into it.

I should mention that it is unlikely that all recipients will
be listed in the sender's address book and probably undesirable
that they be added.
 
I believe I also suggested declaring and instantiating a Recipient object
from the return value of the Recipients.Add() function and then calling the
Resolve() method on that recipient.

Dim oRecip As Outlook.Recipient
With objOutMsg
Set oRecip = .Recipients.Add(strRecipient)
oRecip.Resolve
If oRecip.Resolved Then
.Send
Else
MsgBox "recip not resolved"
End If




.Len B said:
I was referred here by Ken Slovak when I posted the question below
to the outlook.interop group. At Ken's suggestion I added a namespace
and performed a logon to it. That produced the same error description
but different error numbers. I am not familiar with the Outlook object
model but I guess I can expect that I'll need to be soon.

----------
I am trying to use MS Access 2003 to automate the sending of a number
of messages. I have the following code (stolen from MS KB161088 and
modified) which fails with error code -1594867707 (a0f04005) when
executing the .Send method. Googling the hex error gave zero results
and Googling the decimal error yielded runtime errors with differing
numbers, none of which were relevant.

Clicking on Help from the error dialog brings up help on error
440 - Automation.

The text of the error is: Outlook does not recognize one or more
names. Googling this yields a Microsoft support page suggesting
that the address book is corrupt. I can successfully send e-mail
directly from OL and the sole test recipient is my own email
address which does appear in my address book.

Dim objOut As Outlook.Application
Dim objOutMsg As Outlook.MailItem
Dim oNS as Outlook.NameSpace 'suggested by Ken Slovak
Dim strRecipient As String, strSubject As String
Dim strBody As String
Dim blnDisplayMsg As Boolean

blnDisplayMsg = Me.chkDisplay 'do we display the email first
Set objOut = CreateObject("Outlook.Application") 'Create Outlook session
Set oNS = objOut.GetNamespace("MAPI") 'suggested by Ken Slovak
oNS.Logon "","", False, False 'suggested by Ken Slovak
...
Set objOutMsg = objOut.CreateItem(olMailItem) 'create Outlook message
With objOutMsg
.recipients.Add strRecipient 'To field
.subject = strSubject 'Subject field
.body = strBody 'Body field
If blnDisplayMsg Then 'display before sending
.Display
Else 'just send it
.Save
===> .Send
End If
End With 'done with this message
'erase just sent msg from memory
Set objOutMsg = Nothing

If I send the logic through the .Display method instead, OL fires
and the fields are correctly populated. Clicking on the [Send]
button has the expected result. However, requiring the user to
click send on multiple messages somewhat defeats the purpose.

I hope I am asking in the right forum.
Where to from here?
----------
I am developing on OL2003 connected to POP3 at my ISP.
Target system is OL2003 with Exchange Server [SBS 2003].

I am running into the "object model guard" issue but Ken gave me
a link so that I can look into it.

I should mention that it is unlikely that all recipients will
be listed in the sender's address book and probably undesirable
that they be added.
 
Thanks Ken,
My Internet connection went down there for a while.
The app is now able to send ok.
Thanks again for your help.
--
Len
______________________________________________________
remove nothing for valid email address.
|I believe I also suggested declaring and instantiating a Recipient
object
| from the return value of the Recipients.Add() function and then calling
the
| Resolve() method on that recipient.
|
| Dim oRecip As Outlook.Recipient
| With objOutMsg
| Set oRecip = .Recipients.Add(strRecipient)
| oRecip.Resolve
| If oRecip.Resolved Then
| .Send
| Else
| MsgBox "recip not resolved"
| End If
|
| --
| Ken Slovak
| [MVP - Outlook]
| http://www.slovaktech.com
| Author: Professional Programming Outlook 2007.
| Reminder Manager, Extended Reminders, Attachment Options.
| http://www.slovaktech.com/products.htm
|
|
| | >I was referred here by Ken Slovak when I posted the question below
| > to the outlook.interop group. At Ken's suggestion I added a namespace
| > and performed a logon to it. That produced the same error description
| > but different error numbers. I am not familiar with the Outlook
object
| > model but I guess I can expect that I'll need to be soon.
| >
| > ----------
| > I am trying to use MS Access 2003 to automate the sending of a number
| > of messages. I have the following code (stolen from MS KB161088 and
| > modified) which fails with error code -1594867707 (a0f04005) when
| > executing the .Send method. Googling the hex error gave zero results
| > and Googling the decimal error yielded runtime errors with differing
| > numbers, none of which were relevant.
| >
| > Clicking on Help from the error dialog brings up help on error
| > 440 - Automation.
| >
| > The text of the error is: Outlook does not recognize one or more
| > names. Googling this yields a Microsoft support page suggesting
| > that the address book is corrupt. I can successfully send e-mail
| > directly from OL and the sole test recipient is my own email
| > address which does appear in my address book.
| >
| > Dim objOut As Outlook.Application
| > Dim objOutMsg As Outlook.MailItem
| > Dim oNS as Outlook.NameSpace 'suggested by Ken Slovak
| > Dim strRecipient As String, strSubject As String
| > Dim strBody As String
| > Dim blnDisplayMsg As Boolean
| >
| > blnDisplayMsg = Me.chkDisplay 'do we display the email first
| > Set objOut = CreateObject("Outlook.Application") 'Create Outlook
session
| > Set oNS = objOut.GetNamespace("MAPI") 'suggested by Ken Slovak
| > oNS.Logon "","", False, False 'suggested by Ken Slovak
| > ...
| > Set objOutMsg = objOut.CreateItem(olMailItem) 'create Outlook
message
| > With objOutMsg
| > .recipients.Add strRecipient 'To field
| > .subject = strSubject 'Subject field
| > .body = strBody 'Body field
| > If blnDisplayMsg Then 'display before sending
| > .Display
| > Else 'just send it
| > .Save
| > ===> .Send
| > End If
| > End With 'done with this message
| > 'erase just sent msg from memory
| > Set objOutMsg = Nothing
| >
| > If I send the logic through the .Display method instead, OL fires
| > and the fields are correctly populated. Clicking on the [Send]
| > button has the expected result. However, requiring the user to
| > click send on multiple messages somewhat defeats the purpose.
| >
| > I hope I am asking in the right forum.
| > Where to from here?
| > ----------
| > I am developing on OL2003 connected to POP3 at my ISP.
| > Target system is OL2003 with Exchange Server [SBS 2003].
| >
| > I am running into the "object model guard" issue but Ken gave me
| > a link so that I can look into it.
| >
| > I should mention that it is unlikely that all recipients will
| > be listed in the sender's address book and probably undesirable
| > that they be added.
| >
| > --
| > Len
| > ______________________________________________________
| > remove nothing for valid email address.
| >
| >
|
 
Back
Top