can you send two objects in one email using the sendobject

  • Thread starter Thread starter Guest
  • Start date Start date
In
D Rius said:
I want to send two queries in one email using the sendobject, is this
possible?

No, not using SendObject. Bypassing SendObject, you could separately
save each query as either a separate sheet in a single Excel workbook,
or as a separate workbook, and then use MAPI or Outlook automation to
create an e-mail, attach the file(s), and send it.

For a lot of links on sending e-mails from Access, see Tony Toews'
Access Email FAQ:

http://www.granite.ab.ca/access/email.htm
 
Thank you so much for your help. When you are referring to saving each query
as a separate sheet in an Excel Workbook would this have to be done manually
or can it be done programmatically?
 
In
D Rius said:
Thank you so much for your help. When you are referring to saving
each query as a separate sheet in an Excel Workbook would this have
to be done manually or can it be done programmatically?

Sure, it can be done programmatically with ease. You use the
DoCmd.TransferSpreadsheet method. To export two queries to separate
sheets in the same workbook, you would use code similar to this:

'----- start of example code -----

Dim strOutputFile As String

strOutputFile = "C:\Temp\MyExcelFile.xls"

DoCmd.TransferSpreadsheet _
acExport, _
acSpreadsheetTypeExcel9, _
"Query1", _
strOutputFile, _
True

DoCmd.TransferSpreadsheet _
acExport, _
acSpreadsheetTypeExcel9, _
"Query2", _
strOutputFile, _
True

'----- end of example code -----

Since the code didn't specify the Range argument for
TransferSpreadsheet, that will create (or replace) worksheets named
"Query1" and "Query2" in the Excel workbook. The workbook itself will
be created if it doesn't already exist.

If you want, you can name the worksheets when you export the queries, as
in this example:

DoCmd.TransferSpreadsheet _
acExport, _
acSpreadsheetTypeExcel9, _
"Query1", _
strOutputFile, _
True, _
"Sales"

DoCmd.TransferSpreadsheet _
acExport, _
acSpreadsheetTypeExcel9, _
"Query2", _
strOutputFile, _
True, _
"Revenue"
 
Back
Top