I have a program that will send a report to email addresses contained in a table. The problem is that Outlook opens and I have to click on the "send" button everytime before the program loops and the next email is created. How do I programmatically click on the "send" button. Also, if there is a way to delete all of these emails from my "sent items" folder that would be useful too. The code is posted below. Thanks. Mike
Private Sub cmd_test_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim vIPA_NUM As String
Dim strReport As String
Dim strReportPath As String
strReportPath = "c:\"
strReport = "1 rpt_Summary"
Set db = CurrentDb
Set rs = db.OpenRecordset("tblEmail")
rs.MoveFirst
Do
DoCmd.SetWarnings False
vIPA_NUM = rs.Fields("IPA_NUM")
DoCmd.RunSQL "SELECT DATA1.* INTO [1 rpt_Summary] FROM DATA1 WHERE (((DATA1.IPA_NUM)= '" & vIPA_NUM & "'))", -1
DoCmd.SendObject acSendReport, "1 rpt_Summary", "MicrosoftExcelBiff8(*.xls)", rs.Fields("Email_Address"), "", "", "1 rpt_Summary", "Please find attached your report", True
rs.MoveNext
Loop Until rs.EOF
DoCmd.SetWarnings True
rs.Close
db.Close
End Sub
Private Sub cmd_test_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim vIPA_NUM As String
Dim strReport As String
Dim strReportPath As String
strReportPath = "c:\"
strReport = "1 rpt_Summary"
Set db = CurrentDb
Set rs = db.OpenRecordset("tblEmail")
rs.MoveFirst
Do
DoCmd.SetWarnings False
vIPA_NUM = rs.Fields("IPA_NUM")
DoCmd.RunSQL "SELECT DATA1.* INTO [1 rpt_Summary] FROM DATA1 WHERE (((DATA1.IPA_NUM)= '" & vIPA_NUM & "'))", -1
DoCmd.SendObject acSendReport, "1 rpt_Summary", "MicrosoftExcelBiff8(*.xls)", rs.Fields("Email_Address"), "", "", "1 rpt_Summary", "Please find attached your report", True
rs.MoveNext
Loop Until rs.EOF
DoCmd.SetWarnings True
rs.Close
db.Close
End Sub