Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SendObject Action ... multiple objects?

Status
Not open for further replies.

ghnat

MIS
Apr 8, 2003
28
CA
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.

If not , is there another way?

thanks
 
I haven't tried this, but have you tried separating the objects using ";"? IE, object1; object2; object3?
 
roymurray: it doesn't work that way.

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

Kill "C:\Windows\Temp\Report1.xls"
Kill "C:\Windows\Temp\Report2.xls"

'and clean up, otherwise you'll blame me for low computer resources...
Set myMailItem=Nothing
MyOlApp.Close
Set MyOlApp=Nothing
End Sub

A mail server that supports automation: ArGoSoft from

Good luck.



[pipe]
Daniel Vlas
Systems Consultant
danvlas@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top