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