Sunday, February 19, 2012

Send mail using Yahoo SMTP server using ASP.Net

This program will send mail from your yahoo SMTP server. Change username and password of the following code and use your yahoo username and password.

Step 1) Download the EASendMail package for send mail. Trial version is freely available. But it will not work after one month. Here is the following link to download package.

Step 2)Unzip the file and add EASendMail20.dll file if you use .net framework 2. otherwise choose .dll file depending upon your .net framework

Step 3) Add following code in your ASP.Net page.And put your yahoo username and password
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using System.Collections.Generic;
using EASendMail; //add EASendMail namespace

public partial class _Default : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)
            SmtpMail oMail = new SmtpMail("TryIt");
            SmtpClient oSmtp = new SmtpClient();

            // Your yahoo email address
            oMail.From = "";

            // Set recipient email address
            oMail.To = "";

            // Set email subject
            oMail.Subject = "test email from yahoo account";

            // Set email body
            oMail.TextBody = "this is a test email sent from c# project with yahoo.";

            // Yahoo SMTP server address
            SmtpServer oServer = new SmtpServer("");

            // For example: your email is "", then the user should be ""
            oServer.User = "";
            oServer.Password = "password";

            // Because yahoo deploys SMTP server on 465 port with direct SSL connection.
            // So we should change the port to 465.
            oServer.Port = 465;

            // detect SSL type automatically
            oServer.ConnectType = SmtpConnectType.ConnectSSLAuto;

                Response.Write("start to send email over SSL ...");
                oSmtp.SendMail(oServer, oMail);
                Response.Write("Email was sent successfully!");
            catch (Exception ep)
                Response.Write("failed to send email with the following error:");



  1. You just like collecting money from people for what you can make free

  2. Sending Email with Yahoo in

  3. Thank you for the information, I think this article is very useful for all who read it.