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