Below is a click event in a button. When I run it, soon as it gets to
mClient.Send(msg) line, it pauses for a few seconds and throws
an exception "Failure to send mail".
What is wrong in my code?
All help, suggestions will be appreciated.
imports system.Net.Mail
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim msg As New MailMessage
Dim mClient As New SmtpClient
'Dim sent As Integer
mClient.Host = "mailservername.com"
mClient.UseDefaultCredentials = True
msg.From = New MailAddress("myemailAddress@company.com")
msg.To.Add(New MailAddress("toCoWorker@company.com"))
msg.Subject = "Testing email program"
msg.Body = "If you receive this, please smile and let me know that it went through."
Try
mClient.Send(msg)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
mClient.Send(msg) line, it pauses for a few seconds and throws
an exception "Failure to send mail".
What is wrong in my code?
All help, suggestions will be appreciated.
imports system.Net.Mail
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim msg As New MailMessage
Dim mClient As New SmtpClient
'Dim sent As Integer
mClient.Host = "mailservername.com"
mClient.UseDefaultCredentials = True
msg.From = New MailAddress("myemailAddress@company.com")
msg.To.Add(New MailAddress("toCoWorker@company.com"))
msg.Subject = "Testing email program"
msg.Body = "If you receive this, please smile and let me know that it went through."
Try
mClient.Send(msg)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub