Ok, ho risolto sistemandolo così
codice:
<%
Dim form, subject, allegato
%>
<Html>
<head>
<title>Email spedita</title>
</head>
<body>
<%
Dim oUpload
Set oUpload = new cUpload
oUpload.SetPath "upload\"
oUpload.Load
if oUpload.Count=0 then
allegato = ""
Else
While Not oUpload.EOF
oUpload.Save()
allegato = oUpload.GetFileName()
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=Javascript: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") = "smtp.fastwebnet.it"
' 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 = "mia_mail@hotmai.it"
objMail.To = oUpload.Form("destinatario")
objMail.Subject = subject
objMail.TextBody = testo
If Len(allegato) <> 0 then
objMail.AddAttachment Server.MapPath("upload\" & allegato)
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=Javascript:history.go(-2)>Torna indietro</a>"
response.write "</td></tr></table></div>"
End sub
%>
</body>
</html>
Grazie, Roby.
Solo due domande:
1) Così come ho fatto va bene? C'è qualcosa che ho fatto a "modo mio" ma che si dovrebbe/potrebbe fare meglio?
2) Una volta spedito il file, mi servirebbe che venisse eliminato dal server: potete dirmi come?
Ringrazio in anticipo ^^