ciao a tutti
sto cercando di creare un Inviare il contenuto di un form come allegato email
in rete ho trovato questo script in asp
sapete quali sono i parametri da modificare per farlo funzionare![]()
![]()
Codice:<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%> <% Dim strMessage Dim strNome Dim strCognome Dim strCommento Dim strFile, strFilePath Dim objFso Dim objFile Dim objMail ' Dettagli per l'invio dell'email Const strDestinatario = "miaemail@indirizzo.it" Const strMittente = "mittente@email.it" Const strOggetto = "Email inviata tramite form" ' Imposta a true per rimuovere il file dopo l'invio Const blnDelete = false ' Controlla l'invio della form if Request.Querystring("send") = 1 AND Len(Request.Form("submit")) > 0 then ' Richiama i dati dalla form strNome = Request.Form("nome") strCognome = Request.Form("cognome") strCommento = Request.Form("commento") ' Crea il nome strFile = "emailatt-" &_ Year(Now()) & Month(Now()) & Day(Now()) & "-" & Clng(Timer()) & ".txt" ' Ricava il percorso del file sul server strFilePath = Server.MapPath(strFile) ' Crea il file sul server Set objFso = Server.CreateObject("Scripting.FileSystemObject") Set objFile = objFso.CreateTextFile(strFilePath, true) objFile.WriteLine("Email inviata il " & Date() & " alle " & Time()) objFile.WriteLine("IP: " & Request.ServerVariables("REMOTE_ADDR")) objFile.WriteLine("Client: " & Request.ServerVariables("HTTP_USER_AGENT")) objFile.WriteLine("Nominativo: " & strNome & " " & strCognome) objFile.WriteBlankLines(1) objFile.Writeline(strCommento) objFile.Close Set objFile = Nothing Set objFso = Nothing ' Crea l'oggetto CDONTS Set objMail = Server.CreateObject("CDONTS.NewMail") with objMail ' Mittente .From = strMittente ' Destinatario .To = strDestinatario ' Oggetto .Subject = strOggetto ' Corpo dell'email .Body = "Allegato contenuto email." ' Impostazioni .BodyFormat = 1 ' testo .MailFormat = 1 ' testo .Importance = 1 ' normale ' Allegato .AttachFile strFilePath ' Invia l'email .Send end with Set objMail = Nothing ' Elimina il file dal server se richiesto if blnDelete then Set objFso = Server.CreateObject("Scripting.FileSystemObject") ' Controlla la presenza del file ed elimina if objFso.fileExists(strFilePath) then objFso.deleteFile(strFilePath) end if Set objFso = Nothing end if strMessage = "<p>L'email è stata inviata correttamente.<br />" strMessage = strMessage & "Il contenuto della form è stato allegato all'email.</p>" end if %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>freeasp.html.it - Inviare via email in allegato il contenuto di una form</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> </head> <body> <% if Len(strMessage) > 0 then Response.Write(strMessage) else %> <form name="frmEmail" method="post" action="?send=1"> <br />Nome <br /><input type="text" name="nome" value="" /> <br />Cognome <br /><input type="text" name="cognome" value="" /> <br />Commento <br /><textarea name="commento"></textarea> <br /><input type="submit" name="submit" value="invia" /> </form> <% end if %> </body> </html>

LinkBack URL
About LinkBacks
