hi all,
I have a report that I'm attavhing to an email in a button click.
now I've been asked to also add the report to the email body.
I've tried several ways but none of them seems to work.
please see below my none working code:
Private Sub Command64_Click()
On Error GoTo Err
Dim message As String
Dim rs As Recordset
Dim vRecipientList As String
Dim vMsg As String
Dim vSubject As String
Dim strRep As Report_Summary
Set rs = CurrentDb.OpenRecordset("SELECT * FROM Mail_list")
If rs.RecordCount > 0 Then
rs.MoveFirst
Do
If Not IsNull(rs!email) Then
vRecipientList = vRecipientList & rs!email & ";"
rs.MoveNext
Else
rs.MoveNext
End If
Loop Until rs.EOF
vMsg = "Site:" & Me.Customer_Name & vbCrLf & "Report:" & strRep
vSubject = "Supporter Daily Report"
DoCmd.SendObject acSendReport, "Summary", acFormatPDF, vRecipientList, , , vSubject, vMsg, True
MsgBox ("Report successfully eMailed!")
Else
MsgBox "No contacts."
End If
Exit Sub
Err:
Exit Sub
End Sub
I have a report that I'm attavhing to an email in a button click.
now I've been asked to also add the report to the email body.
I've tried several ways but none of them seems to work.
please see below my none working code:
Private Sub Command64_Click()
On Error GoTo Err
Dim message As String
Dim rs As Recordset
Dim vRecipientList As String
Dim vMsg As String
Dim vSubject As String
Dim strRep As Report_Summary
Set rs = CurrentDb.OpenRecordset("SELECT * FROM Mail_list")
If rs.RecordCount > 0 Then
rs.MoveFirst
Do
If Not IsNull(rs!email) Then
vRecipientList = vRecipientList & rs!email & ";"
rs.MoveNext
Else
rs.MoveNext
End If
Loop Until rs.EOF
vMsg = "Site:" & Me.Customer_Name & vbCrLf & "Report:" & strRep
vSubject = "Supporter Daily Report"
DoCmd.SendObject acSendReport, "Summary", acFormatPDF, vRecipientList, , , vSubject, vMsg, True
MsgBox ("Report successfully eMailed!")
Else
MsgBox "No contacts."
End If
Exit Sub
Err:
Exit Sub
End Sub