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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I use sendobject to send more than one report?

Status
Not open for further replies.

shaunacol

Programmer
Jan 29, 2001
226
0
0
GB
I am using the following code which is working OK and sends my report into OUtlook....

DoCmd.SendObject acSendReport, "Rpt_FPM report", acFormatRTF, ASMEmail.Value, , , "FPM Report", "Please find FPM reports attached", -1

I would really like to attach 2 reports to the same email - is that possible, I tried the code below but it does not work.

DoCmd.SendObject acSendReport, "Rpt_FPM report" & "Rpt_ASMReport", acFormatRTF, ASMEmail.Value, , , "FPM Report", "Please find FPM reports attached", -1

Any help would be appreciated.
Ta

 
Sorry, as far as I know you can not do that. It would have to be two different emails.
Pat B
 
You will need to use docmd > outputto to create the files on your hard drive. Then you will need to create a mail object in Microsoft Outlook (you will need to set a reference to Outlook) and attach the files to the object. Once this is done the files can be deleted from your hard drive.
 
Here is how you would do what deboyz suggested. Remember you will need to set an Outlook reference under Tools -> References.

Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment

' CREATE OUTLOOK SESSION
Set objOutlook = CreateObject("Outlook.Application")
' CREATE THE MESSAGE
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

With objOutlookMsg

Set objOutlookRecip = .recipients.Add("person@test.com")
objOutlookRecip.Type = olTo

' SET THE SUBJECT AND BODY OF THE EMAIL
.Subject = "Text of Subject"
******Use one of the following lines depending on whether ******you want to send an HTML body or a Plain Text body
.HTMLBody = "HTML Code for Body"
.Body = "Plain Text of the Body"

' SET THE ATTACHMENTS
.Attachments.Add ("c:\filename1.ext")
.Attachments.Add ("c:\filename2.ext")

' RESOLVE ALL RECIPIENTS OF THE EMAIL
For Each objOutlookRecip In .recipients
objOutlookRecip.Resolve
Next

' IF TO BE DISPLAYED, THEN DISPLAY, OTHERWISE SEND IT.
***** Use one of the following to send the message.
***** .Display will display the message before sending it
.Display
.Send

End With
Set objOutlook = Nothing


This should work for you. If you would like a basic help file on using Outlook Items from Access go to this web site: Pat B
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top