Any web application is in complete without mail functionality you should have to write send mail functionality. Like if there is shopping cart application for example then when a order created on the shopping cart you need to send an email to administrator of website for Order notification and for customer you need to send an email of receipt of order. So any web application is not complete without sending email. This post is also all about sending email. In post I will explain that how we can send emails from our Gmail Account without purchasing any smtp server etc.
There are some limitations for sending email from Gmail Account. Please note following things.
So if you are using mail functionality for limited emails then Gmail is Best option. But if you are sending thousand of email daily then it will not be Good Idea.
Here is the code for sending mail from Gmail Account.
public partial class WebForm1 : System.Web.UI.Page
protected void Page_Load(object sender,System.EventArgs e)
MailMessage mailMessage = new MailMessage(new MailAddress("firstname.lastname@example.org")
mailMessage.Subject = "Sending mail through gmail account";
mailMessage.IsBodyHtml = true;
mailMessage.Body = "<B>Sending mail thorugh gmail from asp.net</B>";
System.Net.NetworkCredential networkCredentials = new
SmtpClient smtpClient = new SmtpClient();
smtpClient.EnableSsl = true;
smtpClient.UseDefaultCredentials = false;
smtpClient.Credentials = networkCredentials;
smtpClient.Host = "smtp.gmail.com";
smtpClient.Port = 587;
Response.Write("Mail Successfully sent");
That’s run this application and you will get like below in your account.
Hope this will help you.. Stay tuned for more..
Tags: C#.NET, #DOTNET, #ASP.NET, DOTNET, #.NET, Email, System.Net.Mail,