Hi Guys
Code:
Dim oApp As New Outlook.ApplicationDim oEmail As Outlook.MailItem
Dim fileName As String, todayDate As String
Dim Date1 As String
Dim Date2 As String
Date1 = Format(Text10, "DD-MM-YYYY")
Date2 = Format(Text12, "DD-MM-YYYY")
'Export report in same folder as db with date stamp
todayDate = Format(Date, "MMDDYYYY")
fileName = Application.CurrentProject.Path & "\Performances From " & Date1 & " To " & Date2 & ".pdf"
DoCmd.OutputTo acReport, "Performances", acFormatPDF, fileName, False
'Email the results of the report generated
Set oEmail = oApp.CreateItem(olMailItem)
With oEmail
.Recipients.Add "user@gmail.com"
.Subject = "Lecturer Performances From " & Date1 & " To " & Date2
.Body = "Dear Staff Members" & vbNewLine & "I here with attach the performane report of lecturers from " & Date1 & " to " & Date2
.Attachments.Add fileName
.Send
End With
MsgBox "Email successfully sent!", vbInformation, "EMAIL STATUS"
I am using above code to send automated email upon a button click. as you can see here i have hardcoded the receivers email address ".Recipients.Add "user@gmail.com", instead of hardcoding the email is there is a way give the user a prompt to type the email addresses?