emailing from within access

rneaul

New member
Local time
Today, 03:06
Joined
Oct 16, 2012
Messages
4
All,
I am trying to automate the process of sending a query result via email.

I have code that will export a query as an excel document, using DoCmd.SendObject, but it has the name of the query.
DoCmd.SendObject acSendQuery, "Dailyrpt", acFormatXLSX, email.address, , , "Daily Report", "This is today's report", -1, False (email.address would actually be the email address it is being sent to.)

I also have code that will export the query to excel and save it as a file, using DoCmd.OutputTo, where I was able to name it something meaningful to the end user, and include the date.
DoCmd.OutputTo acOutputQuery, "Dailyrpt", acFormatXLSX, "Z:\Folder\Complete as of " & Format(Date, "yyyymmdd") & ".xlsx"
Dim Foldername As String
Foldername = "Z:\Folder\Complete as of " & Format(Date, "yyyymmdd") & ".xlsx"
Shell "C:\Program Files (x86)\Microsoft Office\Office14\EXCEL.exe """ & Foldername & "", vbNormalFocus

Is there a way to either send the saved (renamed) file or to include the current date as part of the SendObject command?

:banghead:
Thank you,
Roland
 
Last edited:
Are you using Outlook for email?

I would save output the file, create an email in outlook, attach the file to email, send/display the email then delete the file afterwards if you don't want to keep it.
 
Acorpolis, I was looking for a more automated option. I did manage to call one procedure from the other. So it works, but not very elegant. thanks
 
You can fully automate the process outlined, the only way you could automate it any further would be if the app just did it without you starting it ;)
 

Users who are viewing this thread

Back
Top Bottom