本文介绍了想要发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我想在我的Web应用程序中添加一个电子邮件选项,如果有人提交任何查询,则它将发送到任何特定的电子邮件ID,但出现错误,例如"System.Runtime.InteropServices.COMException:传输无法连接到服务器. "

我正在使用此代码


Hi ALL,

I want to add one email option in my web application,if any person submit any query then it will send to any specific email id but having an error like "System.Runtime.InteropServices.COMException: The transport failed to connect to the server."

i am using this code


//System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
MailMessage msg = new MailMessage();
SmtpMail.SmtpServer = "localhost";
msg.To = "[email protected]";
msg.From = "[email protected]";
msg.Subject = "Customer Query";
msg.BodyFormat = MailFormat.Html;
msg.BodyFormat = MailFormat.Text;
msg.Body = "Name : ("+TextBox1.Text+")";
//msg.Body = "E-Mail : ("+TextBox2.Text+")";
//msg.Body = "Phone : ("+TextBox3.Text+")";
//msg.Body = "Check In : ("+TextBox4.Text+")";
//msg.Body = "Country : ("+DropDownList1.SelectedValue+")";
//msg.Body = "Query : ("+TextBox5.Text+") ";
SmtpMail.Send(msg);



任何人都可以帮助我.

任何帮助将不胜感激.



any body can please help me.

any help will be appreciated .

推荐答案

<system.net>
    <mailsettings>
      <smtp from="[email protected]">
        <network host="some_server" port="25" username="name" password="password" defaultcredentials="true" />
      </smtp>
    </mailsettings>
 </system.net>



您也可以在此处 http://www.aspnettutorials.com/tutorials/email/ [ ^ ]



You can also find tutorials here http://www.aspnettutorials.com/tutorials/email/[^]




这篇关于想要发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 09:58