我的代码 有时候可以发送邮件
有的时候 就提示 未能访问cdo.message
谁能帮我看看啊?
private void button2_Click(object sender, System.EventArgs e)
{
   string from,to,cc,bcc,subject,body;
   from=this.textBox1.Text;
to=this.textBox2.Text;
cc=this.textBox3.Text;
bcc=this.textBox4.Text;
subject=this.textBox5.Text;
body=this.richTextBox1.Text;
try
{ MailMessage aMessage=new MailMessage();
//创建一个MailMessage对象
aMessage.From=from;
//定义发信人地址,如果是多人可以用“,”分开
aMessage.To=to;
//定义收信人地址,如果是多人可以用“,”分开
aMessage.Cc=cc;
//定义抄送人地址,如果是多人可以用“,”分开
aMessage.Bcc=bcc;
//定义暗送人地址,如果是多人可以用“,”分开
aMessage.Subject=subject;
//定义邮件主题
aMessage.Body=body;
//定义邮件内容
aMessage.BodyFormat=MailFormat.Text; 
//设置正文格式
aMessage.Fields["http://schemas.microsoft.com/cdo/configuration/sendusing"] = 2;
aMessage.Fields["http://schemas.microsoft.com/cdo/configuration/sendemailaddress"]=from;
aMessage.Fields["http://schemas.microsoft.com/cdo/configuration/smtpaccountname"] = from;// "[email protected]"
aMessage.Fields["http://schemas.microsoft.com/cdo/configuration/sendusername"] = "gqtyddd";//验证账号:发送者邮箱账号
aMessage.Fields["http://schemas.microsoft.com/cdo/configuration/sendpassword"] = "xxxxxx"; //验证密码:发送者邮箱密码
aMessage.Fields["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"] = 1; //验证级别0,1,2
aMessage.Fields["http://schemas.microsoft.com/cdo/configuration/languagecode"] = 0x0804;//语言代码
aMessage.Fields["http://schemas.microsoft.com/cdo/configuration/smtpserver"] = "smtp.163.com"; //SMTP Server
SmtpMail.SmtpServer="smtp.163.com";
SmtpMail.Send(aMessage);

//发送电子邮件
MessageBox.Show("电子邮件已经发送到->"+to);
//this.textBox2.Text="";
//this.textBox5.Text="";
//this.richTextBox1.Text="";
}
catch (Exception ex)
{
//throw ex;
MessageBox.Show(ex.Message.ToString());
}}