Emailing Reports

Wicklund

Registered User.
Local time
Today, 07:16
Joined
Jun 7, 2002
Messages
56
I am using the docmd.sendobject command to send a report as an .snp file. What I would like to do now, is to send .snp files for two reports. Can I do this with the sendobject command??

My code is: DoCmd.SendObject acReport, stDocName, "SnapshotFormat(*.snp)", , , , stSubject


Thank you
 
Not too sure what your request is but if:

Your trying to send 2 reports in 1 email then send object wont work I'm afraid! You can only send 1 object at a time with sendobject.

However you can of course send the report twice in 2 emails.


Otherwise its a case of having a look at the Outlook object model and writing your own email code.
 
I know this is not exactly what you were looking for but it may be an option for you. I basicaly created a table to hold all the report names I wanted to send.

Next I did a little code that will loop though the report names and send each of the reports to the recipiants. The only problem is that it does not put them in one email. It fires up as many emails as you have reports. Because of that it may not be that practical for you. I posted it anyway because some one may know of a way to alter it to suit your needs.

If your email addresses are consistant you may want to consider storing them in a table or code so that you do not have to fill out the To: everytime.
Code:
Dim rsReport As DAO.Recordset
Dim strReport As String

Set rsReport = CurrentDb.OpenRecordset("ReportTable")
' Replace ReportTable with the name of your table that
' holds the reports

Do While Not rsReport.EOF

strReport = rsReport.Fields("Report").Value
' Replace "Report" with the name of the field in the
' table that holds your report names.

DoCmd.SendObject acReport, strReport, _
    "RichTextFormat(*.rtf)", "email@somewhere.com", _
    , , "Subject", "Message Text", False

rsReport.MoveNext

Loop

Set rsReport = Nothing
Since you are not filling in your email addresses in code you may have to change the false to a true to get it to work the way it should. I hope this helps a little.
 

Users who are viewing this thread

Back
Top Bottom