473,549 Members | 2,592 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Emailing to schools on our database

7 New Member
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.CreateOb ject("ADODB.Con nection")
Set myCmd = Server.CreateOb ject("ADODB.Com mand")
Set myRS = Server.CreateOb ject("ADODB.Rec ordset")


Set Mailer = Server.CreateOb ject ("SMTPsvg.Maile r")
Mailer.FromName = "Joe's Widgets Corp."
Mailer.FromAddr ess = "sales@joeswidg ets.com"
Mailer.Subject = "Your Widget Order"
Mailer.BodyText = "Your order was processed."
Mailer.RemoteHo st = "mail-fwd.rapidsite.n et"

myConn.Open("ds n= ;uid= ;password= ")


strSQL = "SELECT tblselectedscho ols.fldContact, tblselectedscho ols.fldemail FROM tblschools RIGHT JOIN tblselectedscho ols ON tblschools.fldS CHOOL_ID = tblselectedscho ols.fldSCHOOL_I D WHERE tblselectedscho ols.fldUserID = " & UserID & " AND tblselectedscho ols.fldSelected = 1"

With myCmd
.ActiveConnecti on = myConn

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

With myCmd2
.ActiveConnecti on = myConn

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

strSQL2 = "UPDATE tblselectedscho ols 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.AddRecip ient myRS.Fields("fl dContact"), myRS.Fields("fl demail")
Else
Mailer.AddBCC myRS.Fields("fl dContact"), myRS.Fields("fl demail")

End If

Else
' Message send failure
'WRITE 0 TO fldmessagesent in tblselectedscho ols

fldCurrentID = myRS.Fields("fl dID")
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 771

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

Similar topics

0
1463
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 and (ii) a body. 2) Show the last X posts (or, better yet, just the last X titles) on a home page. 3) Show all posts on a "news" page. 4) When a...
2
1904
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 send to a list of about 30 email addresses using CDONTS. My emailing ASP script works by looping through a recordset containing the email addresses,...
2
1959
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. For example, Joe must take an annual CPR class, Bob needs to take his Hearing Test, Ann must take her Eye Exam. The task table keeps the...
5
7369
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 Run-time error. When I run it on an XP machine it crashes, but on an NT box it just generates an unknown error, handled by the error handler. I have...
3
2355
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 email. Any ideas? Thanks in advance.
4
1640
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 currently for our client/server apps.
1
1140
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 once entered into the database would email me the results of the form. I found the tutorials on aspnet101.com (Emailing form results) and they...
2
2230
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 smart? what would be a reasonable number? My second question is related to emailing customers who have an anniversary or a Birthday. Is it possible...
20
1906
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 run. Now I have a number of tables in this database...looking like this: editorial editorialdate, editorialname, editorialcomments press
0
7527
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7459
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7726
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7485
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5097
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3488
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1953
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 we have to send another system
1
1064
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
772
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.