Torna al Thread

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Try Dim mail As New MailMessage Dim smtpClient As SmtpClient Dim IndirizzoIp As String Dim mit As String Dim ad As String If Request.Files.Count > 0 Then Dim File As HttpPostedFile File = Request.Files.Get(0) File.SaveAs(Server.MapPath("allegati/" + GetUploadedFilename(File.FileName))) End If mit = Request.QueryString("ame") ad = Request.QueryString("email") IndirizzoIp = Request.ServerVariables("REMOTE_ADDR") mail.From = New MailAddress(ad, mit) mail.To.Add(New MailAddress("destinatario")) mail.Subject = "oggetto" mail.Body = "Nome/Rag.Soc. =" & mit & vbCrLf & "Indirizzo IP=" & IndirizzoIp & vbCrLf & vbCrLf & "In allegato il file pdf del CV" mail.Attachments.Add(New Attachment("allegati/test.pdf")) 'imposto il server SMTP da usare, quello del mio dominio smtpClient = New SmtpClient("localhost") smtpClient.Send(mail) Response.Write("&success=true") Catch exc As Exception Response.Write(exc.Message) End Try End Sub Private Function GetUploadedFilename(ByVal FullPath As String) As String Return System.IO.Path.GetFileName(FullPath) End Function
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5