Re: Emailing a Report
- From: strive4peace <strive4peace2006@xxxxxxxxx>
- Date: Tue, 23 Jan 2007 10:15:09 -0500
Hi Gus,
here is some basic code you can modify ... if you have trouble, we can help you out more.
If you are confused about creating the SQL statement to get the data that you want, send me an email and request my 30-page Word document on Access Basics (for Programming) -- it doesn't cover VBA, but prepares you for it because it covers essentials in Access.
Be sure to put "Access Basics" in the subject line so that I see your message...
'~~~~~~~~~~~~~~~~~~~
Sub LoopThroughTableAndSendObject( _
pSQL as string )
'Crystal
'strive4peace2007 at yahoo dot com
'NEED reference to
'Microsoft DAO Library
'dimension variables
Dim r As DAO.Recordset, strSQL as string
'Set up error handler
On Error GoTo Err_proc
'PARAMETERS
'pSQL -- defines the recordset to open
' -- this can be a tablename, queryname, or SQL statement..."
'comment or take this line out after procedure is tested
debug.print strSQL
'open the Recordset
Set r = CurrentDb.OpenRecordset(pSQL, dbOpenSnapshot)
'move to the first record
r.MoveFirst
'loop through the Recordset until the end
Do While Not r.EOF
SendObject _
objecttype _
, objectname _
, outputformat _
, r!emailAddressFieldname
, [cc] _
, [bcc] _
, [subject] _
, [messagetext] _
, [editmessage] _
, [templatefile]
r.MoveNext
Loop
Exit_proc:
on error resume next
'close the recordset
r.close
'release object variables
Set r = Nothing
exit sub
Err_proc:
msgbox err.description,,"ERROR " & err.number & " LoopThroughTableAndSendObject"
'press F8 to step through code and see where problem is
'comment next line after routine is debugged
stop : resume
goto Exit_proc
End Sub
'~~~~~~~~~~~~~~~~~~~~~~~~~
Warm Regards,
Crystal
*
(: have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*
Gus wrote:
Thanks for your help Crystal..
My database serves as a reminder system. It stores user inputted nformation about action he or she needs to take on a contract(s) on or by a certain date.
I have a query that looks up all the reminders based on date. For example 01/23/2007, a report will be produced with a list of all users who have an item to be reminded of on the mentioned date.
My question is how can I create the code for sending a message to all the users that appear on the report without having to type in there email address in the address line of the message?
This is the code I am currently using. With this code I can only get one address in the address line of the message, also if the report has no data I get a Run-time error '2498'. I am not yet a very savy VB user, so please, if you can provide as much detail as possible.
Have a great day!
Private Sub Command18_Click()
DoCmd.SendObject _
acSendReport, _
"Daily Reminders All Teams Report", _
acFormatHTML, _
[email], _
, _
, _
"Your Reminder", _
"Good Morning!", _
True
"strive4peace" wrote:
Hi Gus
here are the parameters for SendObject
'SendObject
'[objecttype]
'[, objectname]
'[, outputformat]
'[, to]
'[, cc]
'[, bcc]
'[, subject]
'[, messagetext]
'[, editmessage]
'[, templatefile]
What is your question?
Warm Regards,
Crystal
*
(: have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*
Gus wrote:Hi, Thanks for your help.
I have a DB that stores user reminders. A report has been created to get users who need to be reminded of something they must do on a spcific date.
I am trying to formulate code to be able to send an email with the report for the users that appear on the report. I am using Lotus Notes.
This is the code that I am currently using.
Private Sub Command18_Click()
DoCmd.SendObject _
acSendReport, _
"Daily Reminders All Teams Report", _
acFormatRTF, _
"UserEmail", _
, _
, _
"Your Reminder", _
"Have a good day!", _
False
End Sub
- Follow-Ups:
- Re: Emailing a Report
- From: Gus
- Re: Emailing a Report
- From: strive4peace
- Re: Emailing a Report
- References:
- Re: Emailing a Report
- From: strive4peace
- Re: Emailing a Report
- From: Gus
- Re: Emailing a Report
- Prev by Date: Re: Emailing a Report
- Next by Date: Saving Caculated Text Fields
- Previous by thread: Re: Emailing a Report
- Next by thread: Re: Emailing a Report
- Index(es):
Relevant Pages
|