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)
afastars
Member
52 Points
221 Posts
Fail To Sent Email From Asp.net Page
Dec 30, 2012 02:57 AM|LINK
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
ignatandrei
All-Star
134929 Points
21622 Posts
Moderator
MVP
Re: Fail To Sent Email From Asp.net Page
Dec 30, 2012 03:05 AM|LINK
Catch ex As Exception
'MsgBox(ex)
Label1.Text = "Failed" + ex.Message
End Try
What's the message?
afastars
Member
52 Points
221 Posts
Re: Fail To Sent Email From Asp.net Page
Dec 30, 2012 04:20 AM|LINK
hi ignatandrei
thanks for reply, i just got this is the error message when i implement you code:
Failure sending mail
need help, i really need to implement this ignatandrei
mudassarkhan
All-Star
78956 Points
13402 Posts
MVP
Re: Fail To Sent Email From Asp.net Page
Dec 30, 2012 05:22 AM|LINK
Remove the credentials from Web.Config file and set them in code. Refer
Send Email using Gmail in VB.Net
Contact me
afastars
Member
52 Points
221 Posts
Re: Fail To Sent Email From Asp.net Page
Dec 30, 2012 06:11 AM|LINK
hi mudassarkhan
you resolve my problem tq so much , really appreciate it