L
.Len B
I am trying to use Access 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 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 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?
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 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 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?