I am working MS C# 2008. I created Windows form application. And I need to send email from my application. so how do I configure smtp settings?
我正在使用MS C#2008。我创建了Windows表单应用程序。我需要从我的应用程序发送电子邮件。那我该如何配置smtp设置呢?
EDIT
I got The following Exception
我得到以下例外
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at
SMTP服务器需要安全连接或客户端未经过身份验证。服务器响应为:5.5.1需要身份验证。了解更多信息
on smtp.send(message);
I have not installed IIS so is it required for desktop app?
我没有安装IIS,所以桌面应用程序需要它吗?
2 个解决方案
#1
You can add the SMTP settings within the App.Config http://www.mitchelsellers.com/blogs/articletype/articleview/articleid/8/net-20-smtp-settings.aspx
您可以在App.Config中添加SMTP设置http://www.mitchelsellers.com/blogs/articletype/articleview/articleid/8/net-20-smtp-settings.aspx
And then use System.Net.Mail.SmtpClient and System.Net.Mail.MailMessage to send and create the emails.
然后使用System.Net.Mail.SmtpClient和System.Net.Mail.MailMessage发送和创建电子邮件。
c = new System.Net.Mail.SmtpClient();
msg = new System.Net.Mail.MailMessage();
System.Net.Mail.MailAddress a = new System.Net.Mail.MailAddress( sEmailAddress, sWho );
msg.To.Add( a );
msg.From = new System.Net.Mail.MailAddress("");
msg.ReplyTo = new System.Net.Mail.MailAddress("");
msg.Subject = "Web Inquiry";
msg.Body = msgBody.ToString();
c.Send( msg );
#2
why are a lot of you that are making the "IIS" suggestions using this as the backbone to solve the problem? What if this is a deployed application? you going to have the client install and run IIS on their mediocre system just use the mail functionality of your app???
为什么有很多人正在制作“IIS”建议,以此作为解决问题的主干?如果这是部署的应用程序怎么办?你将安装客户端并在他们平庸的系统上运行IIS只需使用你的应用程序的邮件功能???
That doesn't make sense to me.
这对我来说没有意义。
Those of you looking for a solution on sending emails thru win apps, do a google search on "using gmail to send email in c#".
那些人在寻找通过赢取应用程序发送电子邮件的解决方案,在“使用gmail在c#中发送电子邮件”进行谷歌搜索。
-Rob
#1
You can add the SMTP settings within the App.Config http://www.mitchelsellers.com/blogs/articletype/articleview/articleid/8/net-20-smtp-settings.aspx
您可以在App.Config中添加SMTP设置http://www.mitchelsellers.com/blogs/articletype/articleview/articleid/8/net-20-smtp-settings.aspx
And then use System.Net.Mail.SmtpClient and System.Net.Mail.MailMessage to send and create the emails.
然后使用System.Net.Mail.SmtpClient和System.Net.Mail.MailMessage发送和创建电子邮件。
c = new System.Net.Mail.SmtpClient();
msg = new System.Net.Mail.MailMessage();
System.Net.Mail.MailAddress a = new System.Net.Mail.MailAddress( sEmailAddress, sWho );
msg.To.Add( a );
msg.From = new System.Net.Mail.MailAddress("");
msg.ReplyTo = new System.Net.Mail.MailAddress("");
msg.Subject = "Web Inquiry";
msg.Body = msgBody.ToString();
c.Send( msg );
#2
why are a lot of you that are making the "IIS" suggestions using this as the backbone to solve the problem? What if this is a deployed application? you going to have the client install and run IIS on their mediocre system just use the mail functionality of your app???
为什么有很多人正在制作“IIS”建议,以此作为解决问题的主干?如果这是部署的应用程序怎么办?你将安装客户端并在他们平庸的系统上运行IIS只需使用你的应用程序的邮件功能???
That doesn't make sense to me.
这对我来说没有意义。
Those of you looking for a solution on sending emails thru win apps, do a google search on "using gmail to send email in c#".
那些人在寻找通过赢取应用程序发送电子邮件的解决方案,在“使用gmail在c#中发送电子邮件”进行谷歌搜索。
-Rob