Send email to group of contacts

K

KLR

I am using the following code (from Ron Hughes code to send email to
all database at
http://www.rogersaccesslibrary.com/Otherdownload.asp?SampleName='CodeSendEMailToAll.mdb'.
When clicking the command button, I click on Yes when prompted to
create a new table but at the end the error message "Invalid use of
Null" is displayed. Can anyone help?

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 strTo As String
Dim strCC As String
Dim strBCC As String
Dim strSubj As String
Dim strText 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

strAddress = .Fields("UCASEmail").Value
strBCC = strAddress

.MoveNext

Do While .EOF = False
strAddress = .Fields("UCASEmail").Value
strBCC = strBCC & "; " & strAddress
.MoveNext
Loop
End With

strTo = ""
strCC = ""
strBCC = strBCC
strSubj = ""

strText = Chr$(13) & Chr$(13) & "" & Chr$(13) & ""
'Chr$(13) will insert a blank line in the subject of your EMail.
'Anything between the quotes will be inserted. You can edit, as
required before sending
'If you want the subject to be blank, just put the quotes, with
nothing between them

DoCmd.SendObject acSendNoObject, , , strTo, , strBCC, strSubj,
strText, True

ErrExit:
Exit Sub

ErrHandle:
MsgBox Err.description
Resume ErrExit
Resume

End Sub
 

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