422,952 Members | 2,244 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 422,952 IT Pros & Developers. It's quick & easy.

How send individual report to individual email

P: 3
I have a report of n pages. Each page is a record of different student result information and the student's email address. The report is already filtered out from a query. I want a code that will mail each student's result to the student's corresponding email address directly from access without usiing Outlook. Please, your help will be highly appreciated.

Thank you.
Kennedy Orah
1 Week Ago #1
Share this Question
Share on Google+
6 Replies


twinnyfo
Expert Mod 100+
P: 2,443
Kenorah123,

Welcome to Bytes!

There are mainly two ways to accomplish this:
  • You can use a filter on the Report which is activated in the VBA module behind the report, using a Global Variable which established the filter for that report, save it, and then e-mail it OR
  • You can have the query used as the record source for the Report use similar variables for changing the records returned.

Neither option is extremely complex, but it canbe tricky. This all depends upon your currently level of comfort using VBA.

Without additional details, we can't provide you any more detailed guidance.
1 Week Ago #2

P: 3
Thank you, please, I need more guidance. The detail is: have a report of n pages. Each page is a record of different student result information and the student's email address. The report is already filtered out from a query. I want a code that will mail each student's result to the student's corresponding email address directly from access without usiing Outlook. Please, your help will be highly appreciated.

Thank you.
Kennedy Orah
1 Week Ago #3

twinnyfo
Expert Mod 100+
P: 2,443
Thanks, but you haven't given me anything new.

This solution is fairly straightforward, but I don't know your level of expertise in VBA. I don't know anything about your tables and queries behind this report. I don't know how you are intending to send the Report (you can use SendObject or initiate MS Outlook).

Additionally, and most importantly, you have not shown us what you have tried so far. The experts (and probably most all the others) on this forum have jobs and we don't have time to build something from scratch. We are glad to help troubleshoot your work or guide you through to a solution.
1 Week Ago #4

zmbd
Expert Mod 5K+
P: 5,105
The catch here is mailing without using Outlook as many IT groups are now disabling the CDO or not allowing the CDO to connect to the exchange server.

You will also need to know your SMTP server information such as name and the port it's operating (typically 25) without that information it will be more difficult, if even possible.

What is the particular reason you do not want to use Outlook for the email?
1 Week Ago #5

P: 3
Thank you for willing to help. I am fairly good in VBA. My report name is: "primary each class". The report is derived from "primary each class" query as it's record source. Both the query and the report contains among other fields: studentid, studentemail, etc. I have used EmailDatabaseObject (Access 2016)SendObject macro action, but sends the entire report to all the email provided without filtering them. I don't really mind whether outlook is used or directly send from access as long as it loops and send individual record to individual emailaddress at the click of a button. Your help will be greatly appreciated.
Kennedy
1 Week Ago #6

zmbd
Expert Mod 5K+
P: 5,105
Kenorah123
Ok, that's the normal behavior for a report see my answer here:
https://bytes.com/topic/access/answe...rt#post3817305

Report sent with the SendObject are sent "As Is" found if opened directly.

More than likely with a slight modification to your query that the report is based on using the [TempVars] as shown in the above answer, your vba can set a variable, for example [TempVars]![StudentID], to the value of the student's record you want to send the report for, the query uses this value in the WHERE condition. The query executes, the report is generated, and then is opened for preview, printed, or emailed. The beauty of the [TempVars] is that it is stabled until the current session is closed or it is explicitly cleared.

In anycase... in your code, create your recordset, loop through the recordset and set [TempVars]![StudentID], send your reports.

:)
1 Week Ago #7

Post your reply

Sign in to post your reply or Sign up for a free account.