Formmail

enzonero

Nuovo Utente
ECCO UN CODICE ASP.

<%@LANGUAGE = JScript%>
<%
// Recupero i dati dal modulo
var nome = new String(Request.Form("nome"));
var cognome = new String(Request.Form("cognome"));
var email = new String(Request.Form("email"));
var oggetto = new String(Request.Form("oggetto"));
var importanza = new String(Request.Form("importanza"));
var messaggio = new String(Request.Form("messaggio"));
var html = new String(Request.Form("html"));

// RegExp per l'email
var valida = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;

// Imposto la data
var oggi = new Date();
var data = oggi.getDate() + "/" + (oggi.getMonth() + 1) + "/" + oggi.getYear() + " alle ore " + oggi.getHours() + ":" + oggi.getMinutes();

// Imposto l'indirizzo IP del mittente
var ip = Request.ServerVariables("REMOTE_ADDR");

// Controllo la validità dei campi
if ((nome == "") || (nome == "undefined")) Response.Redirect("errore.htm?id=1");
if ((cognome == "") || (cognome == "undefined")) Response.Redirect("errore.htm?id=2");
if (!valida.test(email)) Response.Redirect("errore.htm?id=3");
if ((oggetto == "") || (oggetto == "undefined")) Response.Redirect("errore.htm?id=4");
if ((messaggio == "") || (messaggio == "undefined")) Response.Redirect("errore.htm?id=5");

// Creo la classe CDONTS.NewMail ed invio l'email
var OggettoCDONTS = new ActiveXObject("CDONTS.NewMail");
OggettoCDONTS.Importance = importanza;
OggettoCDONTS.From = email;
OggettoCDONTS.To = "[email protected]"; // Qui il tuo indirizzo email
OggettoCDONTS.Subject = oggetto;
// Verifica se la mail è in formato Html
if ((html == "") || (html == "undefined")) {
OggettoCDONTS.BodyFormat = 1;
OggettoCDONTS.MailFormat = 1;
OggettoCDONTS.Body = "Dati del mittente\n\nNome: " + nome + "\nCognome: " + cognome + "\nEmail: " + email + "\nIP: " + ip + "\n\nMessaggio spedito il " + data + "\n\nQuesto è il corpo del messaggio:\n\n" + messaggio;
}
else {
OggettoCDONTS.BodyFormat = 0;
OggettoCDONTS.MailFormat = 0;
OggettoCDONTS.Body = "<b>Dati del mittente<br><br>Nome:</b> " + nome + "<br><b>Cognome:</b> " + cognome + "<br><b>Email:</b> " + email + "<br><b>IP</b>: " + ip + "<br><br><i>Messaggio spedito il " + data + "</i><br><br><b>Questo è il corpo del messaggio:</b><br><br>" + messaggio;
}
OggettoCDONTS.Send();

// Reindirizzo il mittente verso la pagina di conferma
Response.Redirect("conferma.htm");
%>
DOVE DEVO METTERE LA EMAIL??????????
GRAZIE:hammer:
 

Discussioni simili