这个发邮件的程序错在那里了啊中是发不出去啊?
protected void btnSend_Click(object sender, EventArgs e)
{
string From = txtMailFrom.Text;
string To = txtMailTo.Text;
string Subject = txtMailSubject.Text;
string Text = FCKeditor1.Value;
//string Att = fudAtt.PostedFile.FileName;
SendMail(From, To, Subject, Text);
}
private void SendMail(string MailFrom, string MailTo, string MailSubject, string MailText)
{
//直接用SmtpMail发送邮件
try
{
MailMessage MM = new MailMessage(MailFrom, MailTo);
MM.Subject = MailSubject;
MM.Body = MailText;
MM.Attachments.Add(new Attachment(fudAtt.PostedFile.InputStream,fudAtt.FileName));
MM.BodyEncoding = System.Text.Encoding.UTF8;
MM.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Send(MM);
FCKeditor1.Value = " ";
reg.msg( "邮件发送成功 ");
}
catch(Exception ex)
{
reg.msg( "邮件发送失败请重新发送 ");
}
}
是不是这一句非要设置 服务器啊 SmtpClient smtp = new SmtpClient();
我设置成这样 SmtpClient smtp = new SmtpClient( "smtp.163.com ");
还是提示失败啊
谁有个成功的例子贴出来下 谢谢
我在网上找了半天 放在我的代码里面就是运行不了啊 要带附件的 谢谢
------解决方案--------------------书上的一个例子:
protected void btSubmit_Click(object sender, EventArgs e)
{
/