I have following code, It works, but only problem I have is when Fields (1) or Fields (3) is empty ( means no email address) then it throws error.
In ON CLICK event
Dim PassWord As String
PassWord = InputBox("Enter Password")
If PassWord = "Hello" Then
' Open Form
'...
Dim MyDb As DAO.Database
Dim rsEmail As DAO.Recordset
Dim sToName As String
Dim sCcName As String
Dim sSubject As String
Dim sMessageBody As String
Set MyDb = CurrentDb()
Set rsEmail = MyDb.OpenRecordset("Followup Email", dbOpenSnapshot)
With rsEmail
.MoveFirst
Do Until rsEmail.EOF
If IsNull(.Fields(0)) = False Then
sToName = .Fields(0) & ";" & .Fields(1)
sCcName = .Fields(2) & ";" & .Fields(3)
sSubject = "Reminder #: " & .Fields(4)
sMessageBody = "Reminder: Please check this item assigned to you showing as Overdue " & vbCrLf & _
"Received From: " & .Fields(5) & ", Due Date: " & .Fields(10) & ", " & .Fields(9) & vbCrLf & _
"Message: " & .Fields(7)
DoCmd.SendObject acSendNoObject, , , _
sToName, sCcName, , sSubject, sMessageBody, False, False
End If
.MoveNext
Loop
End With
Set MyDb = Nothing
Set rsEmail = Nothing
Else
MsgBox ("You're not authorized")
End If
End Sub
In ON CLICK event
Dim PassWord As String
PassWord = InputBox("Enter Password")
If PassWord = "Hello" Then
' Open Form
'...
Dim MyDb As DAO.Database
Dim rsEmail As DAO.Recordset
Dim sToName As String
Dim sCcName As String
Dim sSubject As String
Dim sMessageBody As String
Set MyDb = CurrentDb()
Set rsEmail = MyDb.OpenRecordset("Followup Email", dbOpenSnapshot)
With rsEmail
.MoveFirst
Do Until rsEmail.EOF
If IsNull(.Fields(0)) = False Then
sToName = .Fields(0) & ";" & .Fields(1)
sCcName = .Fields(2) & ";" & .Fields(3)
sSubject = "Reminder #: " & .Fields(4)
sMessageBody = "Reminder: Please check this item assigned to you showing as Overdue " & vbCrLf & _
"Received From: " & .Fields(5) & ", Due Date: " & .Fields(10) & ", " & .Fields(9) & vbCrLf & _
"Message: " & .Fields(7)
DoCmd.SendObject acSendNoObject, , , _
sToName, sCcName, , sSubject, sMessageBody, False, False
End If
.MoveNext
Loop
End With
Set MyDb = Nothing
Set rsEmail = Nothing
Else
MsgBox ("You're not authorized")
End If
End Sub