//file gestione_newsletter//
<%
' CONTROLLA SE SI E' IDENTIFICATI
IF session("amministratore")<>true then
Response.Redirect "index.asp"
End IF
%>
Gestione Newsletter
<%
' LEGGE QUELLO CHE DEVE FARE
operazione = Request.QueryString("tipo")
' PERCORSO DEL DATABASE
url_DB = "driver={Microsoft Access Driver (*.mdb)};dbq=" & server.mappath("../database.mdb")
Set Conn = Server.CreateObject("ADODB.Connection")
conn.Open url_DB
' OPERAZIONE = INVIA IL MESSAGGIO DI NEWSLETTER
IF operazione = "invia" then
' VERIFICA CHE I CAMPI SIANO STATI COMPILATI
IF Request("oggetto") <> "" and Request("testo") <> "" then
' APRE LA CONNESSIONE AL DATABASE E PRELEVA LE EMAIL DELLA NEWSLETTER
Set RecSet = Server.CreateObject("ADODB.Recordset")
SQL = "SELECT * FROM Email_newsletter"
RecSet.Open SQL, Conn, adOpenStatic, adLockOptimistic
IF not RecSet.Eof then
' INDIRIZZO EMAIL NOSTRO
mittente = "info@provider.com"
Do until Recset.eof
' PRELEVA L'EMAIL DELL'UTENTE DAL NOSTRO DATABASE
destinatario = RecSet("Email")
' PRELEVA IL TESTO DEL MESSAGGIO DA INVIARE
testo = Request.Form("testo")
' PRELEVA L'OGGETTO DEL MESSAGGIO DA INVIARE
oggetto = Request.Form("oggetto")
' INVIA IL MESSAGGIO
Set email = CreateObject("CDONTS.NewMail")
email.From = mittente
email.To = destinatario
email.Subject = oggetto
' FORMATO EMAIL
email.BodyFormat = Request.Form("formato")
email.MailFormat = Request.Form("formato")
email.Body = testo
' INVIA L'EMAIL E..
email.Send
Set email = nothing
' PASSA AVANTI...
RecSet.Movenext
loop
End If
RecSet.Close
Conn.close
Set RecSet = Nothing
Set Conn = Nothing
' VISUALIZZA UN MESSAGGIO DI CONFERMA:
%>
Messaggio inviati
correttamente!
<%
Else
%>
Compila tutti i campi!
<%
End IF
Else
%>
<%
End IF
Set Conn = Nothing
Set RecSet = Nothing
%>