0

I want to send email in asp.net using my yahoo account
I want to the know the SMTP server name of yahoo and the port number to use .
Like for gmail i know .its "smtp.gmail.com" and port 587

Whats in case of Yahoo...??
In gmail its free to send...Is it that yahoo CHARGES for sending emails...heard somewhere..it a nt sure...
Is it possible to send email using YAHOO...
Help me out?

4
Contributors
3
Replies
9
Views
8 Years
Discussion Span
Last Post by Sree_1
1
/* yahoo */
    public bool SendYahooMail(string sToEmail, string sFromEmail, string sHeader, string sMessage,string Password)
    {
        SmtpClient client = new SmtpClient();
        client.DeliveryMethod = SmtpDeliveryMethod.Network;
        client.EnableSsl = true;

        client.Host = "smtp.mail.yahoo.co.in";
        client.Port = 587;

        // setup Smtp authentication

        System.Net.NetworkCredential credentials = new System.Net.NetworkCredential(sFromEmail, Password);
        client.UseDefaultCredentials = false;
        client.Credentials = credentials;

        System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
        msg.From = new MailAddress(sFromEmail);
        msg.To.Add(new MailAddress(sToEmail));

        msg.Subject = sHeader;
        msg.IsBodyHtml = true;
        msg.Body = string.Format(sMessage);
        try
        {
            client.Send(msg);
            return true;
        }
        catch (Exception ex)
        {
            return false;            
        }

    }
    /* Gmail*/
    public bool SendGmailMail(string sToEmail, string sFromEmail, string sHeader, string sMessage,string Password)
    {
        SmtpClient client = new SmtpClient();
        client.DeliveryMethod = SmtpDeliveryMethod.Network;
        client.EnableSsl = true;

        client.Host = "smtp.gmail.com";
        client.Port = 587;

        // setup Smtp authentication

        System.Net.NetworkCredential credentials = new System.Net.NetworkCredential(sFromEmail, Password);
        client.UseDefaultCredentials = false;
        client.Credentials = credentials;

        System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
        msg.From = new MailAddress(sFromEmail);
        msg.To.Add(new MailAddress(sToEmail));

        msg.Subject = sHeader;
        msg.IsBodyHtml = true;
        msg.Body = string.Format(sMessage);
        try
        {
            client.Send(msg);
            return true;
        }
        catch (Exception ex)
        {
            return false;            
        }

    }
    //

Edited by Reverend Jim: Fixed formatting

Votes + Comments
Good answer, shame about the lack of [CODE] tags
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.