Click here to Skip to main content
14,601,062 members
Rate this:
Please Sign up or sign in to vote.
See more:
Please i need a code for email sending using yahoo smtp server using localhost !!!

i have gmail smtp server using local host code which is working working perfectly but the same is not not working for yahoo... :(

Help needed :)

Regards
Harsha

Thanks :)
Posted
Comments
JakirBB 30-Jun-12 4:05am
   
Do you want to send email using a yahoo or other mail service providers?
Harsha Dev 30-Jun-12 4:09am
   
using yahoo service!!! :)

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

You can try this.

static void Main(string[] args)
        {
            SmtpMail oMail = new SmtpMail("TryIt");
            SmtpClient oSmtp = new SmtpClient();
        
            // Your yahoo email address
            oMail.From = "myid@yahoo.com";

            // Set recipient email address
            oMail.To = "support@emailarchitect.net";
            
            // 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("smtp.mail.yahoo.com");

            // For example: your email is "myid@yahoo.com", then the user should be "myid@yahoo.com"
            oServer.User = "myid@yahoo.com";
            oServer.Password = "yourpassword";

            // 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;

            try
            {
                Console.WriteLine("start to send email over SSL ...");
                oSmtp.SendMail(oServer, oMail);
                Console.WriteLine("email was sent successfully!");
            }
            catch (Exception ep)
            {
                Console.WriteLine("failed to send email with the following error:");
                Console.WriteLine(ep.Message);
            }
        }


If this don't help you somehow you can check here
   
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100