Salve a tutti
sbirciando qua e la nel forum sto cercando di crearmi un modulo in asp dove potermi, tramite una form, farmi mandare degli allegati...
attualmente ho questo codice:
form.html
codice:<HTML> <HEAD> <TITLE>Manda Email</TITLE> </HEAD> <BODY> <FORM ACTION="manda.asp" METHOD="post" enctype="multipart/form-data"> <div align="center"> <table border="0" width="85%" celpadding="2" cellspacing="2"> <tr> <td> <h1>Manda E-mail<hr align="LEFT" size="1" width="100%" color="navy"></h1> </td> </tr> <tr> <td> Compila il Form </td> </tr> <td align="center"> <table width="60%" border="0" celpadding="2" cellspacing="2"> <tr> <td>Subject</td> <td><INPUT NAME="subject" TYPE="TEXT" size=30 MAXLENGTH=50></td> </tr> <tr> <td>Email destinatario</td> <td valign="top"> <INPUT NAME="destinatario" TYPE="TEXT" ALIGN=left size=30 MAXLENGTH=50></td> </tr> <tr> <td valign="top">Testo</td> <td><TEXTAREA NAME="testo" ROWS=7 COLS=42></TEXTAREA></td> </tr> <tr> <td rowspan="3" valign="top">Allega</td> <td><input type="file" name="file1" /></td> </tr> <tr> <td><input type="file" name="file2" /></td> </tr> <tr> <td><input type="file" name="file3" /></td> </tr> <tr> <td colspan="2" align="center"> <table width="50%" border="0" celpadding="6" cellspacing="2"> <tr> <td><input type="submit" name="invio" value=" Invia "></td> <td align="right"> <INPUT TYPE="reset" NAME="reset" VALUE=" Reset "></td> </tr> </table></td> </tr> </table> </td> </tr> </table> </div> </FORM> </BODY> </HTML>
File upload.asp
codice:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <% Dim form, subject, allegato1, allegato2, allegato3 %> <Html> <head> <title>Email spedita</title> </head> <body> <% Dim oUpload Set oUpload = new cUpload oUpload.SetPath "upload\" oUpload.Load if oUpload.Count=0 then allegato1 = "" allegato2 = "" allegato3 = "" Else While Not oUpload.EOF oUpload.Save() Select Case lCase(oUpload.Files("InputName")) Case "file1" allegato1 = oUpload.GetFileName() Case "file2" allegato2 = oUpload.GetFileName() Case "file3" allegato3 = oUpload.GetFileName() End Select oUpload.MoveNext Wend End if call Main() Sub Main() If Len(oUpload.Form("subject")) = 0 then no_sub() else manda_posta(form) ecco_fatto(nome) end if Set oUpload=Nothing End sub Sub no_sub() response.write "<div align='center'>" response.write "<table border='0' width='80%' cellspadding='4' cellspacing='4'>" response.write "<tr><td>Non hai inserito un subject</td></tr>" response.write "<tr><td>Per favore, torna indiedro e inseriscine uno </td></tr>" response.write "<tr><td align='middlè>" response.write "<a href=java-script:history.go(-1)>Pagina precedente</a>" response.write "</td></tr></table></div>" End Sub Sub manda_posta(form) Dim subject, testo Dim objMail, objMailConfig subject = oUpload.Form("subject") mittente = oUpload.Form("mittente") testo = oUpload.Form("testo") Set objMail = Server.CreateObject("CDO.Message") Set objMailConfig = Server.CreateObject ("CDO.Configuration") ' Proprietà di invio with objMailConfig ' SMTP mail server .Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.eurnetcity.net" ' SMTP port .Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 ' CDO port .Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 ' Timeout .Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60 .Fields.Update end with Set objMail.Configuration = objMailConfig objMail.From = "r.didonato@infotrading.it" objMail.To = oUpload.Form("destinatario") objMail.Subject = subject objMail.TextBody = testo If Len(allegato1) <> 0 then objMail.AddAttachment Server.MapPath("upload\" & allegato1) end if If Len(allegato2) <> 0 then objMail.AddAttachment Server.MapPath("upload\" & allegato2) end if If Len(allegato3) <> 0 then objMail.AddAttachment Server.MapPath("upload\" & allegato3) end if objMail.Fields("urn:schemas:httpmail:importance").Value = 0 objMail.Fields.update() objMail.Send Set objMail = Nothing end sub Sub ecco_fatto(nome) response.write "<div align='center'>" response.write "<table border='0' width='80%' cellspadding='4' cellspacing='4'>" response.write "<tr><td>Grazie " & subject & " per la mail</td></tr>" response.write "<tr><td align='middlè>" response.write "<a href=java-script:history.go(-2)>Torna indietro</a>" response.write "</td></tr></table></div>" End sub %> </body> </html>
manda.asp
questo codice però non mi funziona perchè mi da questo errore:codice:<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Microsoft VBScript runtime error '800a01fa'
Class not defined: 'cUpload'
/landing/upload.asp, line 17
qualcuno sa aiutarmi e nel caso dirmi che cavolata ho scritto???

Rispondi quotando