Sending email to many recipients

K

KLR

I am using the following code to create an Outlook email to be sent to
a group of contacts. I get the error message 'Unknown message
recipients: message not sent' pop up when I run the code. Any ideas
why?


Private Sub SendEmail_Click()

Dim strDocName As String
strDocName = "qmt_ucas_emails"
DoCmd.OpenQuery strDocName

On Error GoTo ErrHandle

Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim strAddress As String
Dim strBCC As String

Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("t_Account Management data",
dbOpenSnapshot)

If rst.BOF = True And rst.EOF = True Then
MsgBox "There must be an error in the query as there are no
EMail Addresses listed!"
GoTo ErrExit
End If

With rst
.MoveFirst
Do While Not .EOF
strAddress = Nz(.Fields("UCASEmail").Value, "")
If strAddress <> "" Then strBCC = strAddress & "; "
.MoveNext
Loop
End With

strBCC = strBCC

DoCmd.SendObject acSendNoObject, , , , , strBCC, , , True

ErrExit:
Exit Sub

ErrHandle:
MsgBox Err.description
Resume ErrExit
Resume

End Sub
 
D

Douglas J. Steele

I doubt this is the problem, but your line of code

If strAddress <> "" Then strBCC = strAddress & "; "

should be

If strAddress <> "" Then strBCC = strBCC & strAddress & "; "

It's possible that you need to remove the final semi-colon from the string.
I also believe you must specify a To value: that you cannot simply specify a
BCC value.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top