C#邮件客户端发送邮件失败问题
我看了MSDN上的例子觉得没错,但为什么发不出去?请达人们帮帮忙啊,谢谢了
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Net.Mail;
using System.Web.Security;
using System.IO;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btSubmit_Click(object sender, EventArgs e)
{
//设置MailMessage类的to属性所需的MailAddress
MailAddress toAddress = new MailAddress(this.tbReceiver.Text);
//设置MailMessage类的from属性所需的MailAddress
MailAddress fromAddress = new MailAddress(this.tbSender.Text);
//新建一个MailMessage类实例
MailMessage message = new MailMessage(fromAddress, toAddress);
//设置这个实例的Subject属性
message.Subject = this.tbSubject.Text;
//设置这个实例的Body属性
message.Body = this.tbMessage.Text;
//添加附件
//获得文件
HttpPostedFile postedFile = file.PostedFile;
//当有附件时
if (postedFile.ContentLength != 0)
{
//声明一个Attachment类实例
Attachment data = new Attachment(postedFile.FileName);
message.Attachments.Add(data);
}
//设置正文格式
if (rblFormat.SelectedItem.Text == "纯文本格式 ")
message.IsBodyHtml = false;
else
message.IsBodyHtml = true;
//添加抄送地址
&nbs