尝试使用Yahoo SMTP设置从Winform应用程序发送邮件时出错 [英] Error While Trying to send mail From Winform Application using Yahoo smtp settings

查看:89
本文介绍了尝试使用Yahoo SMTP设置从Winform应用程序发送邮件时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在尝试从Winform应用程序发送电子邮件.
我为此使用System.Web.mail命名空间,也正在使用MailMessage和SmtpClient类.

我正在使用Yahoo的smtp设置,但无法正常工作(rediffmail出现相同的错误).

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).

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

推荐答案

您必须为此使用Yahoo API
在这里 http://developer.yahoo.com/mail/code/ [ https://developer.apps.yahoo.com/wsregapp/ [ ^ ]

并阅读API文档.
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.


如果您不使用yahoo plus,则需要将enableSsl设置为false.如果我没有记错的话,过去我曾构建过一个类似的应用程序,但我在465端口上遇到了麻烦,并诉诸于587端口,可以在
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[^]


您无法从winform发送电子邮件.
如果您使用的是 Yahoo!加帐户,则可以使用pop-smtp功能.
否则,您可以使用 Gmail 使用Winform发送电子邮件.
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.


这篇关于尝试使用Yahoo SMTP设置从Winform应用程序发送邮件时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆