<%
' change to address of your own SMTP server
strHost = "mail.atlantech.net"
%>
<HEAD>
<TITLE>AspEmail: Database.asp</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<H2>AspEmail: Database.asp</h2>
<h3>Demonstrates sending a message to multiple recipients<BR>whose names and addresses
are stored in a database.</h3>
<%
' connect to the MS Access database in the same directory
strDbPath = Server.MapPath(".") & "\users.mdb"
ConnectStr = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & strDbPath
Set rs = Server.CreateObject("adodb.recordset")
rs.Open "users", ConnectStr, 2, 3
If Request("Send") <> "" Then
' send email to all users
Set Mail = Server.CreateObject("Persits.MailSender" )
Mail.Host = mail.cuao.edu.co
Mail.From = "
[email protected]"
Mail.FromName = "Cesar Augusto Jaramillo"
Mail.Subject = Request("Subject")
Mail.Body = Request("Body")
' read address from DB and put them in the BCC field
While not rs.EOF
Mail.AddBcc rs("email"), rs("name")
rs.MoveNext
Wend
' finally: send message
Mail.Send
Response.Write "Success!"
Else
' simply display the list of users in the database
Response.Write "<B>Currently in the user database:</B><P>"
While not rs.EOF
Response.Write rs("name") & " (" & rs("email") & ")<BR>"
rs.MoveNext
Wend
End If
%>
<FORM ACTION="Database.asp">
Body: <TEXTAREA NAME="Body"></TEXTAREA><BR>
<INPUT TYPE=SUBMIT NAME="Send" VALUE="Send a message to them all">
</FORM>
</BODY>
</HTML>