Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am trying to send email from my winform application.
I am using System.Web.mail NameSpace for this an am using MailMessage and SmtpClient classes.

I am using smtp settings of yahoo but it is not working(Same Error Comes for rediffmail).

C#
System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
System.Net.NetworkCredential cred = new System.Net.NetworkCredential(txtFrom.Text, txtPassword.Text);
mail.To.Add(txtTo.Text);
mail.Subject = "Test Mail";
mail.From = new System.Net.Mail.MailAddress(txtFrom.Text);
mail.IsBodyHtml = true;
mail.Body = "This Mail Is A Test Mail";
if (txtAttachFile.Text != "")
{
 System.Net.Mail.Attachment attach = new                                            System.Net.Mail.Attachment(txtAttachFile.Text);
          mail.Attachments.Add(attach);
}
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.mail.yahoo.com");
smtp.UseDefaultCredentials = false;
smtp.EnableSsl = true;
smtp.Credentials = cred;
smtp.Port = 465;
smtp.Send(mail);
Posted
Updated 10-Mar-11 22:21pm
v2
Comments
Dalek Dave 11-Mar-11 4:21am    
Edited for Readability.

You have to use Yahoo API's for this
Have a look at here http://developer.yahoo.com/mail/code/[^]. Download the c# code. Get an application ID from here https://developer.apps.yahoo.com/wsregapp/[^]

and read API documentations as well.
 
Share this answer
 
Comments
Dalek Dave 11-Mar-11 4:21am    
Useful advice.
Albin Abel 11-Mar-11 4:31am    
Thanks Dalek Dave
If you are not using yahoo plus you will need to set the enableSsl to false. I have built a similar app in the past if i remember correctly I had trouble with port 465 and resorted to port 587 you can download my tutorial at Sending Email with Gmail, Yahoo, AOL, and Live Mail Via SMTP[^]
 
Share this answer
 
v5
You can not send email from you winform.
If you are using Yahoo! Plus Account then you can avail pop - smtp feature.
Or else you can use Gmail to send email using winform.
 
Share this answer
 
Comments
charles henington 19-Mar-11 13:04pm    
can you please explain your post in more detail your english is hard to follow

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