本文介绍了想学习从asp.net应用程序发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已完成以下编码,但无法正常工作,请帮助我从我的网站发送邮件.
请告诉我应该用smtp服务器名称写的内容.
在域管理器中,我可以有两个邮件帐户
CNAME& MX,其中之一是服务器名称
I have done the following coding, but is not working please help me to send a mail from my website.
Please tell me what should be written in smtp server name.
In domain manager I can have two mailing accounts
CNAME & MX which one is server name
public int sendMail(string to, string subject, string body)
{
try
{
SmtpMail.SmtpServer = "mail.secureserver.net";
MailMessage msg = new MailMessage();
msg.From = TxtMail.Text;
msg.To = to;
msg.Subject = subject;
msg.Body = body;
SmtpMail.Send(msg);
return (1);
}
catch
{
return (0);
}
}
protected void BtnSend_Click(object sender, EventArgs e)
{
String to = "[email protected]";
String subject = TxtSub.Text;
String body = TxtMessage.Text;
int status = sendMail(to, subject, body);
if (status == 1)
LblMessage.Text = "your mail has been sent successfully";
else
LblMessage.Text = "sorry! your mail could not be sent";
}
推荐答案
这篇关于想学习从asp.net应用程序发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!