Top 10 email service providers to send emails using asp .net

 In most of our website projects there is a need to send emails to website administrators, users, newsletter subscribers etc. In asp .net we can send emails using System.Net.Mail class. However this class needs SMTP server settings to send emails. To provide necessary SMTP settings we can either use our own SMTP server or we can use SMTP server of third party Email service providers like Rediffmail, Gmail, Hotmail, Yahoo etc. In this article we will see how to send emails using asp .net and email service providers like Rediffmail, Gmail, Hotmail, Yahoo etc.  We will also see list of top 10 email providers we can use to send emails with asp .net.
Note: This method requires internet connection to send emails, you can also send emails without internet connection in asp .net using SmtpDeliveryMethod.SpecifiedPickupDirectory. For more information refer this tutorial.

Step1: Create .aspx markup:

01<table>
02       <tbody><tr>
03           <td colspan="2">
04               <asp:label forecolor="Green" id="lblConfirmation" runat="server">
05           </asp:label></td>
06       </tr>
07       <tr>
08           <td>
09               <b>Email To</b>
10           </td>
11           <td>
12               <asp:textbox runat="server" id="txtEmailTo">
13           </asp:textbox></td>
14       </tr>
15       <tr>
16           <td>
17               <b>Subject</b>
18           </td>
19           <td>
20               <asp:textbox runat="server" id="txtEmailSubject">
21           </asp:textbox></td>
22       </tr>
23       <tr>
24           <td>
25               <b>Body</b>
26           </td>
27           <td>
28               <asp:textbox textmode="MultiLine" runat="server" id="txtEmailBody"height="100px" width="400px">
29           </asp:textbox></td>
30       </tr>
31       <tr>
32           <td>
33                 
34           </td>
35           <td>
36               <asp:button text="Send Email" id="btnSendEmail" runat="server"onclick="btnSendEmail_Click">
37           </asp:button></td>
38       </tr>
39   </tbody></table>


Step2: Add Namespace.

1using System.Net.Mail;
2using System.Net;


Step3: Code Behind.

01//--- Button Click to send emails.
02    protected void btnSendEmail_Click(object sender, EventArgs e)
03    {
04        using (MailMessage mm = new MailMessage())
05        {
06            mm.From = new MailAddress("YourEmailAddress"); //--- Email address of the sender
07            mm.To.Add(txtEmailTo.Text); //---- Email address of the recipient.
08            mm.Subject = txtEmailSubject.Text; //---- Subject of email.
09            mm.Body = txtEmailBody.Text; //---- Content of email.
10            mm.IsBodyHtml = false//---- To specify wether email body contains HTML tags or not.
11
12            SmtpClient smtp = new SmtpClient();
13            smtp.Host = "smtp.gmail.com"//---- SMTP Host Details.
14            smtp.EnableSsl = true//---- Specify whether host accepts SSL Connections or not.
15            NetworkCredential NetworkCred = new NetworkCredential("YourEmailAddress","YourPassword");
16            //---Your Email and password
17            smtp.UseDefaultCredentials = true;
18            smtp.Credentials = NetworkCred;
19            smtp.Port = 587; //---- SMTP Server port number. This varies from host to host.
20            smtp.Send(mm);
21
22            //==== Show confirmation message.
23            lblConfirmation.Text = "Congratulations, Your email successfully sent";
24
25            //---- Clear form fields.
26            txtEmailBody.Text = string.Empty;
27            txtEmailSubject.Text = string.Empty;
28            txtEmailTo.Text = string.Empty;
29        }
30    }


From above example you can see how easily we can use power of asp .net and email service providers to send emails. Here is a list of 10 email service providers you can use to send emails. 
SnoServer NameSMTP AddressPortSSL
1GMailsmtp.gmail.com587Yes
2Hotmailsmtp.live.com587Yes
3Yahoosmtp.mail.yahoo.com587Yes
4Rediffmailsmtp.rediffmail.com587Yes
5Outlooksmtp.live.com587Yes
6AOLsmtp.aol.com587Yes
7AIMsmtp.aim.com587Yes
8Zoho Mailsmtp.zoho.com465Yes
9Mail.comsmtp.mail.com587Yes
10Sify.comsmtp.sify.com587Yes

To use these email service providers you have to just do changes in :
  1. smtp.Host
  2. smpt.EnableSSL
  3. NetworkCredentials
  4. smtp.Port
Example: Suppose you want to send email using your rediff mail and asp .net you need to change these settings only:
1SmtpClient smtp = new SmtpClient();
2           smtp.Host = "smtp.rediffmail.com"//---- SMTP Host Details.
3           smtp.EnableSsl = true//---- Specify whether host accepts SSL Connections or not.
4           NetworkCredential NetworkCred = new NetworkCredential("YourRediffMailId","YourRediffMailPassword");
5           //---Your Email and password
6           smtp.UseDefaultCredentials = true;
7           smtp.Credentials = NetworkCred;
8           smtp.Port = 587; //---- SMTP Server port number. This varies from host to host.
9           smtp.Send(mm);
Final Output:

Comments