i would like to send a specific report "RaceresultsR", to the email addresses listed in a query called Rt_EmailQ and the field name in query is called "Email"
The code below only show a blank "To" block to add addresses manually
please help - DoCmd.SendObject acReport, "RaceresultsR", "HTML(*.html)", "", "", "", "Race results", "", True, ""
Try this Revision: - Dim MyDB As DAO.Database
-
Dim rstEMail As DAO.Recordset
-
Dim strBuild As String
-
Dim strSQL As String
-
-
strSQL = "SELECT Cyclist.Surname, Cyclist.Name, Cyclist.City, Cyclist.Email, RaceEntry.RaceDate " & _
-
"FROM Cyclist INNER JOIN RaceEntry ON Cyclist.IDNo = RaceEntry.IDNo " & _
-
"WHERE Cyclist.Email Is Not Null And RaceEntry.Racedate = #" & [Forms]![Rt_Reportsf]![Racedate] & "# " & _
-
"ORDER BY Cyclist.Surname;"
-
-
Set MyDB = CurrentDb
-
Set rstEMail = MyDB.OpenRecordset(strSQL, dbOpenForwardOnly)
-
-
With rstEMail
-
Do While Not .EOF
-
strBuild = strBuild & ![email] & ";" 'Build the 'TO' String
-
.MoveNext
-
Loop
-
End With
-
-
If strBuild <> "" Then 'At least 1 Recipient
-
strBuild = Left$(strBuild, Len(strBuild) - 1) 'Remove Trailing ';'
-
DoCmd.SendObject acSendReport, "RaceresultsR", "HTML(*.html)", strBuild, "", "", "Race results", "", True, ""
-
End If
-
-
rstEMail.Close
-
Set rstEMail = Nothing
10 9052 - Dim MyDB As DAO.Database
-
Dim rstEMail As DAO.Recordset
-
-
Set MyDB = CurrentDb
-
Set rstEMail = MyDB.OpenRecordset("Rt_EmailQ", dbOpenForwardOnly)
-
-
With rstEMail
-
Do While Not .EOF
-
DoCmd.SendObject acSendReport, "RaceresultsR", "HTML(*.html)", ![email], "", "", "Race results", "", True, ""
-
.MoveNext
-
Loop
-
End With
-
-
rstEMail.Close
-
Set rstEMail = Nothing
Thx Mr Adezzi;
It only adds the first email address in the Rt_EmailQ query to the "To" email column of the email to be send.
I would like the code to take all the email addresses (in "email" text field) listed in this Rt_EmailQ (query), add it to the "To" column in the email where the addresses are separated by ";" for the report called "RaceresultsR".
I then click on the send button and off it go.
Thx for the trouble so far. Is it possible to do this?
- Dim MyDB As DAO.Database
-
Dim rstEMail As DAO.Recordset
-
Dim strBuild As String
-
-
Set MyDB = CurrentDb
-
Set rstEMail = MyDB.OpenRecordset("Rt_EmailQ", dbOpenForwardOnly)
-
-
With rstEMail
-
Do While Not .EOF
-
strBuild = strBuild & ![email] & ";" 'Build the 'TO' String
-
.MoveNext
-
Loop
-
End With
-
-
If strBuild <> "" Then 'At least 1 Recipient
-
strBuild = Left$(strBuild, Len(strBuild) - 1) 'Remove Trailing ';'
-
DoCmd.SendObject acSendReport, "RaceresultsR", "HTML(*.html)", strBuild, "", "", "Race results", "", True, ""
-
End If
-
-
rstEMail.Close
-
Set rstEMail = Nothing
here is an attachment in 2003 if it may help. thx
@neelsfer - No need, the Code in Post #5 will work.
If you open the file i attached, it does not add the different emails addresses from the Rt-EmailQ query, to the same email with the "RaceresultsR" attachment. Please have a look for me. thx
Try this Revision: - Dim MyDB As DAO.Database
-
Dim rstEMail As DAO.Recordset
-
Dim strBuild As String
-
Dim strSQL As String
-
-
strSQL = "SELECT Cyclist.Surname, Cyclist.Name, Cyclist.City, Cyclist.Email, RaceEntry.RaceDate " & _
-
"FROM Cyclist INNER JOIN RaceEntry ON Cyclist.IDNo = RaceEntry.IDNo " & _
-
"WHERE Cyclist.Email Is Not Null And RaceEntry.Racedate = #" & [Forms]![Rt_Reportsf]![Racedate] & "# " & _
-
"ORDER BY Cyclist.Surname;"
-
-
Set MyDB = CurrentDb
-
Set rstEMail = MyDB.OpenRecordset(strSQL, dbOpenForwardOnly)
-
-
With rstEMail
-
Do While Not .EOF
-
strBuild = strBuild & ![email] & ";" 'Build the 'TO' String
-
.MoveNext
-
Loop
-
End With
-
-
If strBuild <> "" Then 'At least 1 Recipient
-
strBuild = Left$(strBuild, Len(strBuild) - 1) 'Remove Trailing ';'
-
DoCmd.SendObject acSendReport, "RaceresultsR", "HTML(*.html)", strBuild, "", "", "Race results", "", True, ""
-
End If
-
-
rstEMail.Close
-
Set rstEMail = Nothing
works great! thx mr Adezzi.
You are quite welcome. The problem was in resolving the Query Parameter Value.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: james00_c |
last post by:
Greetings-
I need to pass multiple email addresses to a "sendto" hidden field in a
form. I need to do that because "CC" and "BCC" are not an option. One
address webmaster@xyz.com would be...
|
by: jdph40 |
last post by:
I'm using Access 97. In the OnClick event of a button I have the code
below. I looks at txtEmail and sends an e-mail message without
further action from the user (user does not have to click Send...
|
by: toufik |
last post by:
Hi,
I've a crystal reports Report, Is it possible to send it by email? how?
Thanks
|
by: Arne Beruldsen |
last post by:
I have a customer database with email addresses. How do I use WebMail to send out a monthly newsletter?
Thanks...Arne
|
by: TCB |
last post by:
How can I separate multiple email addresses entered in a single textbox, the
email addresses are separated by (,) or (;)
Thanks
|
by: mrajanikrishna |
last post by:
Hello Friends,
I am generating two reports but two files.
First report is Shipment Booking Form. After generating this form, I
want to send to the cargo management by email. As far everything...
|
by: donet programmer |
last post by:
Is there a way to map multiple email addresses,
for instance emailadd1@domain.com, emailadd2@domain.com.. etc to one
email address emailadd@domain.com such that when an email is sent to
emailadd1...
|
by: krouxsa |
last post by:
Hi There people...
Please help me with this query.
I want to send 1 email to multiple email addresses stored in a database.
Will it be possible?
I'm using SQL Server 2005 and already set up...
|
by: dragonfly8563 |
last post by:
Hi all,
I created a listbox with employees' names and email addresses in it, and a button which grabs email address once it's clicked. Currently I can only pick up one address at a time, but I...
|
by: farisallil |
last post by:
Hi
I have a table called Info with a column called Email Address in it. I want to create a command button in a form called Customer ,which has the Info table as the Record Source, and I want this...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
| |