Well m searching hard on google but unable to find any working co开发者_如何学运维de that will let me send email using my yahoo id on any account using console application.
Can any body help?
You could try the following:
using (var client = new SmtpClient("smtp.mail.yahoo.com", 587))
{
client.Credentials = new NetworkCredential("youraccount@yahoo.com", "secret");
var mail = new MailMessage();
mail.From = new MailAddress("youraccount@yahoo.com");
mail.To.Add("destaccount@gmail.com");
mail.Subject = "Test mail";
mail.Body = "test body";
client.Send(mail);
}
And if you are using .NET versions prior to 4.0, SmtpClient doesn't implement IDisposable so you might need to remove the using statement around it.
Something like this should do it
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage("from@yahoo.com", "to@domain.com");
message.Subject = "Hello";
message.Body = "Some text";
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.mail.yahoo.com", 465);
smtp.EnableSsl = true;
smtp.Credentials = new System.Net.NetworkCredential("yourusername", "yourpassword");
smtp.UseDefaultCredentials = false;
smtp.Send(message);
Server settings is from http://techblissonline.com/yahoo-pop3-and-smtp-settings/
精彩评论