Visualizzazione dei risultati da 1 a 7 su 7

Discussione: Modulo per E-Mail

  1. #1
    Utente di HTML.it L'avatar di flygigi
    Registrato dal
    Sep 2000
    Messaggi
    259

    Modulo per E-Mail

    Ciao a tutti,
    premetto che di ASP non capisco praticamente nulla, ma in un sito (ereditato) sono costretto ad usarlo ...

    ho una pagina che mi permette di inviare mail attraverso un modulo di tipo POST in cui vi è un campo nome, un campo e-mail e un campo messaggio,
    il file ASP è ua cosa di questo tipo :

    <%
    Set link = CreateObject("CDONTS.Newmail")
    link.From = request.form("email")
    link.To = "mioindirizzo@miodominio"
    link.Subject = "Messaggio dal Form del sito"
    link.Body = request.form("mex")
    link.Send
    Set link = Nothing
    %>
    segue il codice html che viene visualizzato dopo l'inserimento del messaggio.

    Se io volessi creare un'altra pagina con molti più campi (tipo 12 o 13, come faccio a modificare il file ASP per farmi inviare nel corpo della mail il contenuto di tutti i campi ?

    Grazie
    There's no place like /home
    ----------------------------------------
    On contrary of popular belief, Unix *IS* user friendly: it just appears to be selective who it is friend with
    ----------------------------------------
    Real hackers don't die, their TTL expires

  2. #2
    Utente di HTML.it
    Registrato dal
    Feb 2005
    Messaggi
    90
    <%
    Response.Buffer = True
    Response.Expires = 0

    ' pagina su cui reindirizzare
    p = "http://tuosito/errore.htm"

    ' per evitare che la pagina sia richiamata direttamente
    If Request.Form("email") = "" Then Response.Redirect(p)

    For Each Campo in Request.Form
    If Request.Form(campo) = "" Then
    Response.Redirect(p)
    End If
    Next

    Testo = "Contenuto del messaggio...

    "
    Testo = Testo & "Cognome e Nome: " & Request.Form("realname") & "

    "
    Testo = Testo & "Via: " & Request.Form("via") & "

    "
    Testo = Testo & "Città: " & Request.Form("citta") & "

    "
    Testo = Testo & "Prov.: " & Request.Form("prov") & "

    "
    Testo = Testo & "Sesso: " & Request.Form("sesso") & "

    "
    Testo = Testo & "Età: " & Request.Form("eta") & "

    "
    Testo = Testo & "Telefono: " & Request.Form("telefono") & "

    "
    Testo = Testo & "Messaggio:" & Request.Form("messaggio") & "

    "

    Set eMail = Server.CreateObject("CDO.Message")
    With eMail
    .From = Request.Form("email")
    .To = "tua@email.it"
    .Subject = Request.Form("oggetto")
    .TextBody = testo
    .Send()
    End With
    Set eMail = Nothing
    Nome = Request.Form("realname")%>

    dove vedi Request.Form("via") & "

    " vai a sostituire i nomi con quelli che tu hai nel form in htm e con lo stesso sistema:
    Testo = Testo & "Età: " & Request.Form("eta") & "

    "
    inserisci tutti i campi che vuoi purchè abbiano lo stesso nome che hai sul form htm
    qui è inserita anche una pagina che se trova campi vuoti rimanda ad una pagina di errore

    spero di esserti stato d'aiuto
    ciao

  3. #3
    Utente di HTML.it L'avatar di flygigi
    Registrato dal
    Sep 2000
    Messaggi
    259
    Ciao,

    il codice che mi hai consigliato non funziona sul mio server, (dà un errore che adesso non riesco a verificare e non mi ricordo su: "Set eMail = Server.CreateObject("CDO.Message")")
    ho però trovato alcuni esempi in rete che consigliano di fare una cosa del genere :

    <%
    Set link = CreateObject("CDONTS.Newmail")
    link.From = request.form("email")
    link.To = "mia@email.it"
    link.Subject = "oggetto"
    link.BodyFormat = 1
    link.MailFormat = 1
    link.Body = strBody
    strBody = strBody & vbCrLf & "descrizione1" & vbCrLf
    strBody = strBody & vbCrLf & "1" & Request.Form("1") & vbCrLf
    strBody = strBody & vbCrLf & "2" & Request.Form("2") & vbCrLf
    strBody = strBody & vbCrLf & "descrizione2" & vbCrLf
    strBody = strBody & vbCrLf & "3" & Request.Form("3") & vbCrLf
    strBody = strBody & vbCrLf & "4" & Request.Form("4") & vbCrLf
    strBody = strBody & vbCrLf & "5" & Request.Form("5") & vbCrLf
    strBody = strBody & vbCrLf & "6" & Request.Form("6") & vbCrLf
    strBody = strBody & vbCrLf & "7" & Request.Form("7") & vbCrLf
    strBody = strBody & vbCrLf & "8" & Request.Form("8") & vbCrLf
    strBody = strBody & vbCrLf & "9" & Request.Form("9") & vbCrLf
    strBody = strBody & vbCrLf & "10" & Request.Form("10") & vbCrLf
    strBody = strBody & vbCrLf & "11" & Request.Form("11") & vbCrLf
    strBody = strBody & vbCrLf & "12" & Request.Form("12") & vbCrLf
    strBody = strBody & vbCrLf & "13" & Request.Form("13") & vbCrLf
    strBody = strBody & vbCrLf & "14" & Request.Form("14") & vbCrLf
    strBody = strBody & vbCrLf & "15" & Request.Form("15") & vbCrLf
    link.Send
    response.write strbody
    Set link = Nothing
    %>

    Il problema è che il messaggio mi arriva vuoto (cioè rispetta solo il subject ed il destinatario.

    Ho provato anche ad inserire la stringa
    response.write strbody
    per verificare che tutti i campi del modulo vengano letti correttamente, ed infatti in uscita dal modulo sembra che questo avvenga, ma il messaggio continua ad arrivare vuoto.
    There's no place like /home
    ----------------------------------------
    On contrary of popular belief, Unix *IS* user friendly: it just appears to be selective who it is friend with
    ----------------------------------------
    Real hackers don't die, their TTL expires

  4. #4
    Utente di HTML.it
    Registrato dal
    Feb 2005
    Messaggi
    90
    ma sul form in htm i nomi dei campi sono 1,2,3, ecc. oppure hai dei nomi tipo mail, cognome, nome ecc..?

  5. #5
    Utente di HTML.it L'avatar di flygigi
    Registrato dal
    Sep 2000
    Messaggi
    259
    scusa, ho midificato i nomi dei campi per rendere più chiara la formattazione del messaggio ....
    considera che sui form html i campi si chiamino da 1 a 15 e che il codice asp sia una cosa di questo tipo :

    <%
    Set link = CreateObject("CDONTS.Newmail")
    link.From = request.form("2")
    link.To = "mia@email.it"
    link.Subject = "oggetto"
    link.BodyFormat = 1
    link.MailFormat = 1
    link.Body = strBody
    strBody = strBody & vbCrLf & "descrizione1" & vbCrLf
    strBody = strBody & vbCrLf & "1" & Request.Form("1") & vbCrLf
    strBody = strBody & vbCrLf & "2" & Request.Form("2") & vbCrLf
    strBody = strBody & vbCrLf & "descrizione2" & vbCrLf
    strBody = strBody & vbCrLf & "3" & Request.Form("3") & vbCrLf
    strBody = strBody & vbCrLf & "4" & Request.Form("4") & vbCrLf
    strBody = strBody & vbCrLf & "5" & Request.Form("5") & vbCrLf
    strBody = strBody & vbCrLf & "6" & Request.Form("6") & vbCrLf
    strBody = strBody & vbCrLf & "7" & Request.Form("7") & vbCrLf
    strBody = strBody & vbCrLf & "8" & Request.Form("8") & vbCrLf
    strBody = strBody & vbCrLf & "9" & Request.Form("9") & vbCrLf
    strBody = strBody & vbCrLf & "10" & Request.Form("10") & vbCrLf
    strBody = strBody & vbCrLf & "11" & Request.Form("11") & vbCrLf
    strBody = strBody & vbCrLf & "12" & Request.Form("12") & vbCrLf
    strBody = strBody & vbCrLf & "13" & Request.Form("13") & vbCrLf
    strBody = strBody & vbCrLf & "14" & Request.Form("14") & vbCrLf
    strBody = strBody & vbCrLf & "15" & Request.Form("15") & vbCrLf
    link.Send
    response.write strbody
    Set link = Nothing
    %>

    <!--segue codice html--!>

    come mai non mi visualizza il corpo del messaggio pur leggendo correttamente tutti campi ?
    dico così perchè dopo aver impostato
    response.write strbody
    al'uscita dal modulo html la pagina asp mi visualizza il contenuto di tutti i campi in modo corretto (cioè strbody) ed io vorrei che questo mi venisse inviato come corpo del messaggio, ma così non è ...
    cosa devo modificare ?

    ciao
    e grazie
    There's no place like /home
    ----------------------------------------
    On contrary of popular belief, Unix *IS* user friendly: it just appears to be selective who it is friend with
    ----------------------------------------
    Real hackers don't die, their TTL expires

  6. #6
    Utente di HTML.it L'avatar di flygigi
    Registrato dal
    Sep 2000
    Messaggi
    259
    Penso di aver risolto da solo ....
    bastava spostare la riga
    link.Body = strBody
    sotto alle varie definizioni che dicevano "cosa" dovesse contenere, altrimenti veniva letto correttamente dalal pagina asp ma veniva inviato vuoto.

    Ciao & Grazie
    There's no place like /home
    ----------------------------------------
    On contrary of popular belief, Unix *IS* user friendly: it just appears to be selective who it is friend with
    ----------------------------------------
    Real hackers don't die, their TTL expires

  7. #7
    Utente di HTML.it
    Registrato dal
    Feb 2005
    Messaggi
    90
    si infatti nel codice che ti avevo postato io i dati della mail sono sotto i Request.Form ok bene cosi ciao

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.