Quantcast
Channel: Visual Studio and Visual Web Developer Express
Viewing all articles
Browse latest Browse all 3509

Fail To Sent Email From Asp.net Page

$
0
0

hi all expertise

i got problem when sent email from asp.net page below is my code, need help regarding this problem

 Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim sb As New StringBuilder
        sb.Append("EmailAddress")
        sb.Append(txtEmail.text)
        sb.AppendLine()
        sb.Append("Comment")
        sb.Append(txtComments.Text)

        Try
            SendMail("myemailaddress@gmail.com", sb.ToString)
        Catch ex As Exception
            'MsgBox(ex)
            Label1.Text = "Failed"
        End Try


    End Sub

    Protected Sub SendMail(ByVal from As String, ByVal body As String)

        Dim Email As New MailMessage("myemailaddress@gmail.com", txtEmail.Text, "Subject of Email", body)
        Dim smtpClient As SmtpClient = New SmtpClient
        smtpClient.Host = "smtp.gmail.com"
        smtpClient.EnableSsl = True

        Dim credentials As New System.Net.NetworkCredential("username", "password")
        smtpClient.Credentials = credentials
        smtpClient.Send(Email)

        Label1.Text = "Success"

    End Sub


Viewing all articles
Browse latest Browse all 3509

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>