Here is the code As a whole...
The area that seems to not work is thes one:
It will display the email but with only one address in the To: area. It should have multiple as I have 5 entries in my table.
So my guess is that I have something typed incorrectly that I cannot see. Can someone please look it over and tell me where I went wrong.
Thanks,
Rhino
Code:
Private Sub cmdEmail_Click()
On Error GoTo EH
Dim strSendTo As String
Dim strSubject As String
Dim strEMailBody As String
Dim MyDB As DAO.Database
Dim rstEMail As DAO.Recordset
Set MyDB = CurrentDb
Set rstEMail = MyDB.OpenRecordset("Select * From tblEMail", _
dbOpenSnapshot, dbOpenForwardOnly)
With rstEMail
If Not (.BOF And .EOF) Then
Call .MoveFirst
Do While Not .EOF
'Build the Recipients String
strSendTo = ""
strSendTo = _
strSendTo & _
IIf(strSendTo = "", _
"", _
";") & _
!Email
Call .MoveNext
Loop
End If
Call .Close
End With
Call MyDB.Close
Set rstEMail = Nothing
Set MyDB = Nothing
strSubject = "New Part Number Tasks"
strEMailBody = "Please check for tasks you need to perform"
'Generate and Display the E-Mail
Call SendAnEmail(olSendTo:=strSendTo, _
olSubject:=strSubject, _
olEMailBody:=strEMailBody, _
olDisplay:=True, _
SendAsHTML:=True)
Exit Sub
EH:
MsgBox "There was an error sending mail!" & vbCrLf & vbCrLf & _
"Error: " & Err.Number & vbCrLf & _
"Description: " & Err.Description & vbCrLf & vbCrLf & _
"Please contact your Database Administrator.", vbCritical, "WARNING!"
Exit Sub
End Sub
Code:
Set MyDB = CurrentDb
Set rstEMail = MyDB.OpenRecordset("Select * From tblEMail", _
dbOpenSnapshot, dbOpenForwardOnly)
With rstEMail
If Not (.BOF And .EOF) Then
Call .MoveFirst
Do While Not .EOF
'Build the Recipients String
strSendTo = ""
strSendTo = _
strSendTo & _
IIf(strSendTo = "", _
"", _
";") & _
!Email
Call .MoveNext
Loop
End If
Call .Close
End With
Call MyDB.Close
Set rstEMail = Nothing
Set MyDB = Nothing
So my guess is that I have something typed incorrectly that I cannot see. Can someone please look it over and tell me where I went wrong.
Thanks,
Rhino
Comment