想要发送电子邮件 [英] want to send an email

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

问题描述

大家好,

我想在我的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 = "tnitin55@gmail.com";
msg.From = "tnitin55@gmail.com";
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 .

推荐答案

您需要确保smtp服务器的设置正确.通常不使用Localhost.相反,您应该使用配置为邮件服务器的服务器的IP地址或dns名称.

在web.confg文件中进行这些设置的好地方

You need to ensure the setting for the smtp server are correct. Localhost is generally not used. Instead you should us the ip address, or dns name, of the server configured as your mail server.

A good place for these setting is in the web.confg file

<system.net>
    <mailsettings>
      <smtp from="mail@maydomain.com">
        <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/[^]


请参阅本文,以演示发送邮件的查询表
^ ]
see this article that demonstrates query form with sending mail
Send Mail / Contact Form using ASP.NET and C#[^]


在这里查看我的答案

发送电子邮件的asp.net代码错误 [ ^ ]

谢谢
--RA
See my answer here

error in asp.net code to send email[^]

Thanks
--RA


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

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