I have complete working code in vb.net to convert it in C# you can visit
http://converter.telerik.com/[
^]
Imports System.Net.Mail
Imports System.Net
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub SendMail()
' Gmail Address from where you send the mail
Dim fromAddress = "user@domain.com"
' any address where the email will be sending
Dim toAddress = ("recevier@domain.com")
Const fromPassword As String = "Password"
' Passing the values and make a email formate to display
Dim subject As String = ("Abccc")
Dim body As String = "this is body of your email " + vbLf
' smtp settings
Dim smtp = New System.Net.Mail.SmtpClient()
If True Then
smtp.Host = "smtp.domainname.net"
smtp.Port = 25
smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network
smtp.Credentials = New NetworkCredential(fromAddress, fromPassword)
smtp.Timeout = 20000
End If
' Passing values to smtp object
smtp.Send(fromAddress, toAddress, subject, body)
End Sub
Protected Sub btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn.Click
Try
SendMail()
Catch generatedExceptionName As Exception
End Try
End Sub
End Class