%@ LANGUAGE="VBScript" %> <%Option Explicit%>
<% Dim con, rs, strSql, objMail If Request.Form("cmdSubmit") <> "" Then 'The user has submitted the page, so process the Newsletter subscription request 'Connect to the database Set con = GetDBConnection() 'Get all email addresses in the database strSql = "SELECT Email FROM Subscribers" Set rs = Server.CreateObject("ADODB.Recordset") rs.Open strSql, con, 1, 2 If rs.EOF Then 'MODIFY the text below displays when no subscribers exist %> There are no subscribers to the newsletter. <% 'Clean up database objects rs.Close() Set rs = Nothing con.Close() Set con = Nothing Response.End End If While Not(rs.EOF) Set objMail = Server.CreateObject("CDONTS.NewMail") 'MODIFY the following email address will appear as the from address for the email. objMail.From = "newsletter@yoursite.com" objMail.To = rs("Email") objMail.Body = Request.Form("txtEmail") objMail.Send rs.MoveNext() Wend 'MODIFY the text below displays when all the emails have been sent %> The emails have been sent. <% 'Clean up database objects rs.Close() Set rs = Nothing con.Close() Set con = Nothing Else 'MODIFY the text below is displayed when the page is first loaded. %> <% End If %>