Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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

You can try this.

C#
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
 
Share this answer
 
v2
Comments
Michael Haephrati 16-Oct-20 12:16pm    
What is 'SmtpMail'?
Something is missing in your code

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900