Private Sub SendMail_Click()
Dim App As New Outlook.Application
Dim Email As Outlook.MailItem
Dim fileName As String, today As String
today = Format(Date, "DDMMYYYY")
fileName = Application.CurrentProject.Path & "\Report1_" & today & ".pdf"
DoCmd.OutputTo acReport, "Report1", acFormatPDF, fileName, False
Set Email = App.CreateItem(olMailItem)
With Email
.Recipients.Add "ใส่อีเมลผู้รับจดหมาย"
.Subject = "ชื่อเรื่อง"
.Body = "รายละเอียดเนื้อหา"
.Attachments.Add fileName
.Send
End With
MsgBox "ส่ง Email เสร็จแล้ว!", vbInformation, "EMAIL STATUS"
Set Email = Nothing
Set App = Nothing
End Sub