Hi i have an unsolved problem here
I have on my website ( Follow the link to you check the problem http://www.codigoflat.com.br/) a contact form. And when the user send me an email, the page reloads but the contact form is keeping the data.
Running the website on localhost (Visual studio) , is everything okay! But the problem is in the server. Any advice. In advance thanks
my code:
Imports System.Net.Mail
Imports System.Net
Imports System.Data.SqlClient
Public Class WebForm1
Inherits System.Web.UI.Page
Dim dec As New cryptocredentials
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Try
If TextBox5.Text = Session("CaptchaValue").ToString() Then
SendActivationEmail()
Else
ClientScript.RegisterStartupScript([GetType](), "alert", (Convert.ToString("alert('") & "O valor da pergunta de segurança está incorreto. Tente novamente.") + "');", True)
End If
Catch ex As Exception
Finally
End Try
End Sub
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
info()
End Sub
Sub SendActivationEmail()
Try
Dim caminho As String = cryptocredentials.Crypto.Decrypt(dec.Mail)
Dim valor As String = cryptocredentials.Crypto.Decrypt(dec.Acesso)
Using mm As New MailMessage("email", "email")
mm.Subject = "Nova Mensagem enviada através do formulário de contato por:" & Txtnome.Text.Trim()
Dim body As String = ("Mensagem enviada por: ")
body += String.Format(": {0},", Txtnome.Text.Trim())
body += String.Format(" " & "E-mail: {0},", Txtmail.Text.Trim())
body += String.Format(" " & "Assunto: {0},", Txttel.Text.Trim())
body += String.Format(" " & "Mensagem: {0},", Txtmessage.Text.Trim())
body += String.Format(" " & "Arquivos para análise: {0},", Txtlink.Text.Trim())
mm.Body = body
mm.IsBodyHtml = True
Dim smtp As New SmtpClient() With {.Host = "smtp.codigoflat.com.br"}
Dim NetworkCred As New NetworkCredential(caminho, valor)
smtp.UseDefaultCredentials = True
smtp.Credentials = NetworkCred
smtp.Port = 587
smtp.Send(mm)
End Using
Catch ex As Exception
Finally
'Display success message and clear the form.
Dim message As String = "Oi," & " " & Txtnome.Text & " " & "Seu e-mail foi enviado com sucesso! Aguarde contato."
Dim script As String = "window.onload = function(){ alert('"
script &= message
script &= "');"
script &= "window.location = '"
script &= Request.Url.AbsoluteUri
script &= "'; }"
ClientScript.RegisterStartupScript(Me.GetType(), "Mensagem enviada.", script, True)
Response.Redirect(Request.Url.AbsoluteUri)
End Try
End Sub