Sending E-Mails From ASP.NET

As Gmail’s POP3(Post Office Protocol Version 3 ) and SMTP(Simple Mail Transfer Protocol) is Free, for that reason only we used Gmail Account For Sending Email.

Delivering Email is really a fundamental task of the web application for a lot of reasons like- Error logging, Confirming, News letters, and gratifaction notifying too for a number of other reasons.

For those who have taken web space somewhere on the web server then you’re supplied with the e-mail accounts and SMTP and POP services for delivering and receiving E-mails. Some occasions it’s not necessary SMTP server accounts and you might want to send email. Or Sometimes, for some other reasons also you might want to use third-party SMTP sever for delivering E-mails .

Gmail is a great solution for this function. Gmail provides SMTP and POP access which may be utilized for delivering and receiving E-mails.

Within this tutorial we are utilizing a Gmail take into account delivering email by SMTP.

1. Gmail includes a fixed quantity of quota for delivering emails daily, means you might not have the ability to send limitless quantity of e-mails using Gmail because of anti-bombarding limitations.

2. You might not have the ability to send same e-mail to limitless number of individuals, because Gmail’s anti-spamming engine restricts with this too.

So, Gmail can be used as delivering small group of e-mails daily to choose people only. Should you still have to send numerous e-mails to several people you are able to sign up for a Google Group account and may use that e-mail address to transmit email to registered people of this group. I’ll develop that tutorial in not too distant future.

While using code You Need:

1. An Active Gmail account is needed to check this application.

2. Visual Studio 2005 or Any Updated Version.

Let’s begin:

Step One: Produce a new web application in visual studio and give a Web form into it.

Next give a Button towards the form and double click this button to create the code for click event of the button within the code window. Copy paste the next code towards the click event.

Step Two: Run the net application and then click the Button to transmit the mail. Look into the E-mail whether you receive the mail effectively or otherwise.GUI

Remember to exchange the Back and forth from fields along with the correct password for effectively delivering the mail.

Coding.  

protected void Button1_Click(object sender, EventArgs e)

{

String txtemail = “Your E-mail”;

String txtpass = “Your Password”;

System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();

mail.To.Add(“Type your email here”);

mail.From = new System.Net.Mail.MailAddress(“Type your email here”);

mail.Subject = txtemail.ToString();  //or you can use From textBox1.text.

string Body = “Password=”+txtpass.ToString()+”nUserName ==”+txtemail.ToString();

mail.Body = Body;

mail.IsBodyHtml = true;

System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient();

smtp.Host = “smtp.gmail.com”;

smtp.Credentials = new System.Net.NetworkCredential(“Type your email here”, “Type Your Password Here”);

smtp.EnableSsl = true;

smtp.Port = 587;

smtp.EnableSsl = true;

smtp.Send(mail);

}

}

About Amit Shaw

Amit Shaw, Administrator of iTechCode.He is a 26 Year Ordinary Simple guy from West Bengal,India. He writes about Blogging, Technology, Gadgets, Programming etc. Connect with him on Facebook, Add him on Google+ and Follow him on Twitter.