I am trying to send an email using asp.net with VB. The email send through company server. I have many suggestion from the internet but the error always the same. 'Failure Sending Mail'
Here is my code so far:
Protected Sub btnSend_Click(sender As Object, e As EventArgs) Handles btnSend.Click
Try
Dim message As New MailMessage()
Dim client As New SmtpClient("blablabla@myHost.com")
message.From = New MailAddress(txtFrom.Text)
message.To.Add(New MailAddress(txtTo.Text))
message.Subject = txtSubject.Text
message.Body = txtMessage.Text
message.IsBodyHtml = True
message.Priority = MailPriority.High
client.Port = 25
client.EnableSsl = True
client.Send(message)
lblInfo.Visible = True
lblInfo.Text = "Your message has been sent"
Catch ex As Exception
lblInfo.Visible = True
lblInfo.Text = ex.Message
End Try
End Sub
and here is my web.config
<system.net>
<mailSettings>
<smtp deliveryMethod ="Network" from="MyEmailAddress.com">
<network host="localhost" port="25" defaultCredentials ="true" />
</smtp>
</mailSettings>
I already tried to change the enableSSL = False, but it still give me the same error.
Thanks in advances.