Sub send_table_using_send_object() Dim mailto As String Dim ccto As String Dim bccto As String mailto = "koul ashish" ccto = "" bccto = "" emailmsg = "Hi Ashish," & vbNewLine & vbNewLine & "Please find the report attached" mailsub = "Sales Report Dec-2011" On Error Resume Next 'acFormatXLS will export the table into excel format and will add that excel file as attachment DoCmd.SendObject acSendTable, "sales_detail", acFormatXLS, mailto, ccto, bccto, mailsub, emailmsg, True End Sub
Sub send_query_using_send_object() Dim mailto As String Dim ccto As String Dim bccto As String mailto = "koul ashish" ccto = "" bccto = "" emailmsg = "Hi Ashish," & vbNewLine & vbNewLine & "Please find the report attached" mailsub = "Sales Report Dec-2011" On Error Resume Next 'acFormatpdf will export the result of query into pdf format and will add the pdf as attachment DoCmd.SendObject acSendQuery, "rep_name_a", acFormatPDF, mailto, ccto, bccto, mailsub, emailmsg, True End Sub
Sub send_report_using_send_object() DoCmd.SetWarnings (False) Dim mailto As String Dim ccto As String Dim bccto As String mailto = "koul ashish" ccto = "" bccto = "" emailmsg = "Hi Ashish," & vbNewLine & vbNewLine & "Please find the report attached" mailsub = "Sales Report Dec-2011" On Error Resume Next 'acFormatpdf will export the result of query into pdf format and will add the pdf as attachment DoCmd.SendObject acSendReport, "sales_detail", acFormatPDF, mailto, ccto, bccto, mailsub, emailmsg, True DoCmd.SetWarnings (True) End Sub
Sub send_form_using_send_object() Dim mailto As String Dim ccto As String Dim bccto As String mailto = "koul ashish" ccto = "" bccto = "" emailmsg = "Hi Ashish," & vbNewLine & vbNewLine & "Please find the report attached" mailsub = "Sales Report Dec-2011" On Error Resume Next 'acFormatpdf will export the result of query into pdf format and will add the pdf as attachment DoCmd.SendObject acSendForm, "sales_detail", acFormatPDF, mailto, ccto, bccto, mailsub, emailmsg, True End Sub