i Am using below code in vb.net to send email using smtp
The code works well for gmail but when i change smtp name and port number of my organization smtp server anme and port 25 it gives
error "sending email failed"
Please Help
Code:
Dim strmsgbody As String
strmsgbody = "Your Login Deatils For SESS IS" & vbNewLine & "User Name:'" & TextBox1.Text & "'" & vbNewLine & "Password:" & TextBox2.Text & " '"
Using mm As New MailMessage("rahulsankhe2310@gmail.com", txtforpassempemail.Text)
mm.Subject = "Password Recovery Of Schindler Employee Self Service"
mm.Body = strmsgbody
mm.IsBodyHtml = False
Dim smtp As New SmtpClient()
smtp.Host = "smtp.gmail.com"
smtp.EnableSsl = True
Dim NetworkCred As New NetworkCredential("senderemail.text", "senderpassword")
smtp.UseDefaultCredentials = True
smtp.Credentials = NetworkCred
smtp.Port = 587
smtp.Send(mm)
ClientScript.RegisterStartupScript(Me.GetType, "alert", "alert('Email sent.');", True)
End Using
Response.Write("<script type='text/javascript'>alert('PASSWORD ALONG WITH LOGIN DETAILS SEND TO PROVIDED EMAIL ADDRESS');</script>")
txtforpassempcode.Text = ""
txtforpassempemail.Text = ""
Response.Redirect("SESSLogin.aspx", False)
error "sending email failed"
Please Help
Comment