473,405 Members | 2,279 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Automate Emailing of an access report

I have an access 2002 database. I have code that emails an report to people that are in a table. However to send the emails I have to hit the send button on outlook express for each email. Is there are way to NOT have to do this? Below is my code.

Option Compare Database
Option Explicit

Private Sub Command0_Click()
Dim strSQL As String
Dim rs As DAO.Recordset
Dim intLoop As Integer
Dim rpt As Report

On Error GoTo ProcError

strSQL = "SELECT DISTINCT Therapist_Name, email_address FROM tbl_credentialsDue_fromqry"
Set rs = CurrentDb.OpenRecordset(strSQL, , dbfailonerror)
If rs.EOF Then GoTo ProcExit

DoCmd.OpenReport "Policy_letter", acViewPreview
Set rpt = Reports("Policy_letter")

rs.MoveFirst
While Not rs.EOF
rpt.Filter = "[Therapist_Name] = '" & rs("Therapist_Name") & "'"
rpt.FilterOn = True
Pause 1
rpt.Caption = "Policy"
DoCmd.SendObject acSendReport, rpt.Name, acFormatRTF, rs("Email_address"), , , _
"Policy ", "Attached is the Policy, please read."
rs.MoveNext
Wend

ProcExit:
rs.Close
Set rs = Nothing
DoCmd.Close acReport, rpt.Name
Exit Sub

ProcError:
MsgBox Err.Number & vbCrLf & Err.Description, vbOKOnly, "Error sending reports"
Debug.Print Err.Number, Err.Description
Resume ProcExit
End Sub

Public Sub Pause(duration As Double)

'accepts a parameter which is the number of seconds and partial seconds to pause execution of other code.
Dim dblTimer As Double

dblTimer = Timer
While dblTimer + duration > Timer
DoEvents
Wend
End Sub
Apr 14 '10 #1
0 795

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

Similar topics

1
by: Bob-O | last post by:
Need your help in sending an email message with an attachment in my VB.Net program. Sending a body message is no problem. I don't know how to use the attachment property in an emai Following is...
6
by: xzzy | last post by:
I need to automate a report in a different database. Dim RPT as Report Set MyDB = wrkJet.OpenDatabase(Application.CurrentProject.Path & "\Mydb.mdb", True, False) For i = 0 To...
9
by: Brendan MAther | last post by:
I have a table called Contact_Info. I have a form that allows me to show all the contacts from a specified city and sector. Once these contacts appear on my new form I would like to be able to...
6
by: John Galt | last post by:
Does anyone have working code to send a fax from VBA using Outlook.Mailitem? I have tried some examples I have found and they all simply try to use the Fax number as an e-mail address. Thanks in...
2
by: Chuck | last post by:
I have a database that has a table in it with employee information (name, dob, email, etc). This is joined to a table that has tasks that are assigned to each individual that has a recurring date....
16
by: cyranoVR | last post by:
This is the approach I used to automate printing of Microsoft Access reports to PDF format i.e. unattended and without annoying "Save As..." dialogs, and - more importantly - without having to use...
4
by: Salad | last post by:
Hi: I have the following line: DoCmd.SendObject acSendReport, "TestReport", _ "SnapshotFormat (*.snp)", _ "joeblow@nowhere.com", , , "Report Test", _ "Does it open correctly?", True I have...
2
by: sanditaylor | last post by:
Hi There, I'm quite new to access & to VB. I'm working with a database which through a form, you can generate a pdf report (using pdf995). Choose the report from a dropdown box, and then click...
20
by: paul814 | last post by:
I've been working on this for some time now and have gotten nowhere...hoping someone here can help. I want to take and email all records in a database for the current date when this php page is...
1
by: audrey.nsh | last post by:
Hi, I have an Access 97 database where the users loads the data (from multiple sources) and generates forms (that looks like reports) at a click of the button and the user saves the form as .xls...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.