Is it possible to email multiple "objects" (Access tables in Excel format for example) in one email utilizing the "SendObject" action?
It works for 1 object but I would like to add 2 or more to the same email.
SendObject is used to send a single database object by email.
To send more than one, you need to use a mail client or server that supports Automation.
If you use Outlook this is a sample of code:
Sub SendMultipleObjects()
Dim myOlApp
Dim myMailItem
'here is the code to save the objects as files
'so that they can be attached:
DoCmd.OutputTo acOutputReport, "Report1Name", acFormatXLS, "C:\Windows\Temp\Report1.xls"
DoCmd.OutputTo acOutputReport, "Report2Name", acFormatXLS, "C:\Windows\Temp\Report2.xls"
'and so on...You can have a loop here also
'now, set the object variables
Set myOlApp = CreateObject("Outlook.Application"
Set myMailItem = myOlApp.CreateItem(OlMailItem)
With myMailItem
'now fill in the recipients for the message
.To = "whoever@isp.com"
.CC = "Whoever.else@otherisp.com"
.BCC = "Hidden.Recipient@whocares.net"
'put something misleading here
.Subject = "Files you requested"
'blah blah blah part of thr message
.Body = "Hi John, Bye John, nice to see you but I'm out of here"
'add the files (you can use a loop here too
.Attachments.Add "C:\Windows\Temp\Report1.xls"
.Attachments.Add "C:\Windows\Temp\Report2.xls"
'ready, steady, GO..........
.Send
'get rid of the files.You already have them in the SentFolder
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.