Emailing a report

rikklaney1

Registered User.
Local time
Today, 05:37
Joined
Nov 20, 2014
Messages
157
I have a report that I would like to set up to automatically send out at a certain time of day. I have been playing with code I found here and I have this so send an email invisibly...


Private Sub Command0_Click()
Email_Send_To = "email@email.com"
Email_Bcc = "email@email.com"
Email_Body = "Here is the report"
Email_Subject = "report name"

On Error GoTo debugs
Set mail_object = CreateObject("Outlook.Application")
Set mail_single = mail_object.CreateItem(0)
With mail_single
.Subject = Email_Subject
.To = Email_Send_To
.cc = Email_Cc
.BCC = Email_Bcc
.Body = Email_Body

.Send
End With
debugs:
If Err.Description <> "" Then MsgBox Err.Description


Set mail_single = Nothing
If Started Then
mail_object.Quit
End If

End Sub


In the end I will add this to a timed event so nobody has to click anything.
So my question is what do I need to add to this to make it generate and attach a report to this email? Thanks in advance.
 
Use a form that is always open. If there is not one, create one and open it hidden when the db is opened.

Use the OnTimer event set at every, say 5 minutes or however granular you want to get with the sending of the email. In the event, test if the time of day is greater than the required time and that the email has not already been sent that day.

Note that the database has to be open for this to occur.
 
Right... I got that. How do I make it generate and attach the report?
 
Read my recent response to Ingeneeus in
"Need code to e-mail a report-based .pdf via outlook"
 

Users who are viewing this thread

Back
Top Bottom