473,473 Members | 1,854 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Send Individual Emails based on Query

Hi all,

Thank you already for the amount of information that has collected in
this group, very helpful indeed. I have a question in regards to
setting up individual emails to be sent based on a query:

What I currently have is a setup which is pretty much identical to this
(on a standalone access database, not network oriented, single user):

=====================================
Dim strRecipient As String
Dim strSubject As String
Dim strMessageBody As String

strRecipient = "emailaddr...@domain.com"
strSubject = "A New Vendor PO Has Been Entered, PO Number " &
Me![PO_Nbr]
strMessageBody = "This is to notify you that a new Vendor PO has
been entered." & vbCrLf & vbCrLf & vbCrLf & vbCrLf & "PO Number " &
Me![PO_Nbr] & vbCrLf & vbCrLf & vbCrLf & vbCrLf & "This Email has been
generated from the Vendor Repair PO Database, Please DO NOT reply."

DoCmd.SendObject acSendNoObject, , , strRecipient, , , strSubject,
strMessageBody, False
=====================================

What I would like to add however is a script/macro/code which runs when
I open the database in the morning and sends out individual emails
(just like the above), however picking out the records which match a
query. I am not sure what the best way is to go around this and if it's
even possible? I thank you in advance for any help you can provide (I
would also populate a field when the email is sent, so that it doesn't
go out again the next morning. Query depends on days outstanding, i.e.
email is a reminder which is sent at various intervals)

Kind Regards,

Noel

Dec 14 '06 #1
1 2893

no*******@gmail.com wrote:
Hi all,

Thank you already for the amount of information that has collected in
this group, very helpful indeed. I have a question in regards to
setting up individual emails to be sent based on a query:

What I currently have is a setup which is pretty much identical to this
(on a standalone access database, not network oriented, single user):

=====================================
Dim strRecipient As String
Dim strSubject As String
Dim strMessageBody As String

strRecipient = "emailaddr...@domain.com"
strSubject = "A New Vendor PO Has Been Entered, PO Number " &
Me![PO_Nbr]
strMessageBody = "This is to notify you that a new Vendor PO has
been entered." & vbCrLf & vbCrLf & vbCrLf & vbCrLf & "PO Number " &
Me![PO_Nbr] & vbCrLf & vbCrLf & vbCrLf & vbCrLf & "This Email has been
generated from the Vendor Repair PO Database, Please DO NOT reply."

DoCmd.SendObject acSendNoObject, , , strRecipient, , , strSubject,
strMessageBody, False
=====================================

What I would like to add however is a script/macro/code which runs when
I open the database in the morning and sends out individual emails
(just like the above), however picking out the records which match a
query. I am not sure what the best way is to go around this and if it's
even possible? I thank you in advance for any help you can provide (I
would also populate a field when the email is sent, so that it doesn't
go out again the next morning. Query depends on days outstanding, i.e.
email is a reminder which is sent at various intervals)

Kind Regards,

Noel
Open a recordset off the query and then loop through the recordset.
then use the SendObject command inside the loop.

Something along the lines of :
'---UNTESTED AIR CODE
Sub SendAllMessages()
dim qdf as dao.querydef
dim rst as dao.recordset

set qdf=DBEngine(0)(0).Querydefs("YourSelectQuery")
set rst=qdf.OpenRecordset

do until rst.EOF
DoCmd.SendObject acSendNoObject,,, rst.Fields("EMailAddress")
'<--Fill in the args as necessary from the recordset
rst.MoveNext
Loop

rst.Close
set rst=nothing
set qdf=nothing
End sub

Dec 15 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Thom McGrath | last post by:
I'm writing a simple mailing list program, and I would like to know what the suggested method of sending a large number of emails to a list of addresses. (sounds like spam, no?) It's perfectly...
2
by: Kindler Chase | last post by:
win2k server IIS5 CDO Mail Using CDO mail, I'm looping through several email addresses and sending emails. Everything works fine, however, I'd like to set a variable based on the success or not...
2
by: serendipity | last post by:
Hi, I'm not sure if this is possible as i've googled everywhere, but i have a select query that returns a customer record with their associated sales orders. I would like to automate a process...
1
by: Dean | last post by:
I am using MailMessage (CDOSYS) to send emails. I would like to turn off the SMTP service (it's on the local machine) and look at the emails in the pickup folder before they get sent out. However,...
0
by: vijay_kerji | last post by:
Dear Friends, Is it efficient and correct way to utilize web service to query/Update the database and send emails to recipients based on the retrieved data? In other words can web service be...
10
by: Mike Charney | last post by:
Is there a simple way to send SMTP email from Access VBA? Mike m charney at dunlap hospital dot org
1
by: Jeremy | last post by:
I have a table with user names and their balance. I am going to say there are 1000 people that need to get an email of their balance statement. I have one query that pulls the names and the...
0
by: =?Utf-8?B?UmljaA==?= | last post by:
Hello, My company will be hosting a webcast, and I need to send out 2000 individual emails to people who signed up (for login information...). I created an smtp app that I can loop through...
1
by: whisper26 | last post by:
Hi Firstly I'm using Access 2003 for my little project. I've got a bit of a problem. Basically I've been designing a database which has a table for supplier contact details,another containing...
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.