.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

sending mail form gmail smtp server in asp.net

Posted By: kokila     Posted Date: April 03, 2011    Points:5   Category :ASP.Net
hello sir, this is my code
Imports System.Net
Imports System.Net.Mail
Imports System.Net.Mail.SmtpClient
Imports System.Net.Configuration
Partial Class testing
Inherits System.Web.UI.Page
Dim from As String
Dim t As String
Dim s As String

Dim errorMessage As String
Dim ex2 As Exception
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
from = "kokikrish12@gmail.com"
t = "karthi1988@gmail.com"
Dim mail As New System.Net.Mail.MailMessage(from, t)
mail.From = New MailAddress(from, "One Ghost", System.Text.Encoding.UTF8)
mail.Subject = "This is a test mail"
mail.SubjectEncoding = System.Text.Encoding.UTF8
mail.Body = "This is Email Body Text"
mail.BodyEncoding = System.Text.Encoding.UTF8
mail.IsBodyHtml = True
mail.Priority = MailPriority.High
Dim smtp As SmtpClient = New SmtpClient()
smtp.Credentials = New System.Net.NetworkCredential(from, "MYpassword")
smtp.Port = 587
smtp.Host = "smtp.gmail.com"
smtp.EnableSsl = True
Label1.Text = "mail send successfully"

End Sub
End Class

iam getting error msg as "The remote certificate is invalid according to the validation procedure."
pls tell me how to rectify my error and help me to send mail pls pls

Author: Sunil Yadav       [Moderator]      
Posted Date: April 03, 2011     Points: 20   

Post Reply

You must Sign In To post reply
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend