Imports System.Net.Mail Imports System.Net Partial Class Contact Inherits System.Web.UI.Page Public Property Credentials As ICredentialsByHost Protected Sub ok_Click(sender As Object, e As EventArgs) Handles ok.Click Dim fromaddr As String = txtemail.Text Dim toaddr As String = "Email Address" Dim password As String = "Password" Dim msg As MailMessage Dim smtp As SmtpClient Dim nc As NetworkCredential msg = New MailMessage() msg.Subject = lname.Text msg.From = New MailAddress(fromaddr) msg.Body = txtquery.Text msg.To.Add(New MailAddress(txtemail.Text)) smtp = New SmtpClient() smtp.Credentials = New System.Net.NetworkCredential(fromaddr, password) smtp.Host = "smtp.gmail.com" smtp.Port = 587 smtp.UseDefaultCredentials = False smtp.EnableSsl = True smtp.Send(msg) Try smtp.Send(msg) MsgBox("email sent") Catch ex As Exception Response.Write("<script>alert('" + ex.ToString() + "');</script>") End Try End Sub End Class
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)