473,394 Members | 1,759 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,394 software developers and data experts.

Emailing to schools on our database

Am trying to write some vbscript coding to send emails to records on our schools database. This is how far I've got. Am not an expert!! :

<%

Dim myConn, myCmd, myRS, firstRecord
dim strSQL2, fldCurrentID, myCmd2 'NEW


Set myConn = Server.CreateObject("ADODB.Connection")
Set myCmd = Server.CreateObject("ADODB.Command")
Set myRS = Server.CreateObject("ADODB.Recordset")


Set Mailer = Server.CreateObject ("SMTPsvg.Mailer")
Mailer.FromName = "Joe's Widgets Corp."
Mailer.FromAddress = "sales@joeswidgets.com"
Mailer.Subject = "Your Widget Order"
Mailer.BodyText = "Your order was processed."
Mailer.RemoteHost = "mail-fwd.rapidsite.net"

myConn.Open("dsn= ;uid= ;password= ")


strSQL = "SELECT tblselectedschools.fldContact, tblselectedschools.fldemail FROM tblschools RIGHT JOIN tblselectedschools ON tblschools.fldSCHOOL_ID = tblselectedschools.fldSCHOOL_ID WHERE tblselectedschools.fldUserID = " & UserID & " AND tblselectedschools.fldSelected = 1"

With myCmd
.ActiveConnection = myConn

.CommandText = strSQL ' This should be your SQL select statement
.CommandType = 1 'adCmdText
End With

With myCmd2
.ActiveConnection = myConn

.CommandText = strSQL ' This is the SQL statement for UPDATE query to change the fldmessagesent field
.CommandType = 1 'adCmdText
End With

strSQL2 = "UPDATE tblselectedschools SET fldmessagesent=0 WHERE fldID = " & fldCurrentID



myRS.Open myCmd

firstRecord=1

Do While Not myRS.EOF

if Mailer.SendMail then
' Message sent sucessfully

If firstRecord = 1 Then
firstRecord = 0
Mailer.AddRecipient myRS.Fields("fldContact"), myRS.Fields("fldemail")
Else
Mailer.AddBCC myRS.Fields("fldContact"), myRS.Fields("fldemail")

End If

Else
' Message send failure
'WRITE 0 TO fldmessagesent in tblselectedschools

fldCurrentID = myRS.Fields("fldID")
myRS.Open myCmd2
myRS.Close myCmd2


end if


myRS.MoveNext()
Loop

MyFile.Close()
myConn.Close()



%>


The idea is to set fldmessagesent=1 by default and only set it to false(0) if the message is not sent, but having the two myRS.OpenMyCmd... statements nested - will this work, or is there a better way of doing it.

Also, as there may be 1000 emails or more, should they be sent in "blocks" of say 50 at a time. If so, how can I do that?

Anyone's help would be much appreciated

Brian
Sep 18 '07 #1
0 766

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

Similar topics

0
by: Jonathan M. Rose | last post by:
I am looking for a script that I can sit on an HTML server (Linux, Apache, PHP/Perl/Python/Etc.) that will allow me to do the following things: 1) Post news articles that consists of (i) a title...
2
by: Paul Hudson | last post by:
Ive developed a web based system where somebody can add a news record using ASP and MS Access database connectivity. The new record is inserted into the database and then a formatted email gets...
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....
5
by: Colin Anderson | last post by:
I discovered, with great excitement, this article http://www.davison.uk.net/vb2notes.asp when researching methods for emailing from Access via Notes. Unfortunatly, when I run this I get a...
3
by: Strasser | last post by:
In Access2000 mass emailing worked perfectly (very powerful tool!). Doesn't work when using XP version of both Access and Outlook, even though I checked the box to ensure that I was sending the...
4
by: Mike Moore | last post by:
What is the best way to launch outlook from an asp.net web page? Can you do this using MAPI or is there a control that you can purchase? We are unable to use SMTP. We use MS Exhange and MAPI...
1
by: dman | last post by:
Hi, I am a total newbie to asp.net. I have spent the last week or so trying to find a good tutorial that would show me how to create a form that would be entered into a SQL database and then...
2
by: Tim Hunter | last post by:
I have two questions regarding emailing from Access. My first question relates to how many email addresses is too much. I have a client who wants to email 1500 people at once. Is this possible or...
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...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...

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.