Below is an example of how I send email from a command button. I would like to attach a query to this email as an Excel Spreadsheet. I know how to send queries as Excel Spreadsheets but can anyone tell me how to attached a Query to the Email automatically as an Excel File?
Code:
Private Sub OneThreeCurrentFaults_Click()
SendMail1
End Sub
Sub SendMail1()
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Dim clsSendObject As accSendObject
Dim strMsg As String
Dim emailsubject As String
Dim emailtext As String
Dim SL As String, DL As String
Dim toemail As String
SL = vbNewLine
DL = SL & SL
emailsubject = "Please see attached Current Work Unit Faults Spreadsheet for 1-3T Line"
emailtext = Now() & DL & _
"Please see attached Excel Spreadsheet showing today's Work Unit Faults" & DL & _
"Thank You,"
toemail = "abhwinte@nmhg.com"
Set clsSendObject = New accSendObject
strMsg = String(3000, "a")
clsSendObject.SendObject , , accOutputrtf, _
toemail, , "abajacks@nmhg.com", emailsubject, emailtext, True
Set clsSendObject = Nothing
End Sub