我的代码 有时候可以发送邮件
有的时候 就提示 未能访问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());
}}
有的时候 就提示 未能访问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());
}}
解决方案 »
- 如何用程序设定Server2008里面IIS的ISAPI and CGI
- ASP.NET,后台弹出提示框,页面不刷新
- Graphics在何处实例化?
- ado.net能否与access数据库*.mdb连接,请给个连接的例子,谢谢!
- e.Graphics.DrawString 打印的问题
- datagrid表头如何显示中文
- 模态窗口关闭之后,重新刷新加载GridView控件的数据
- 如何通过分析网页源代码获取想要的数据?
- 急---C# 内如何实现 string 和 int之间的转换
- 是不是数据库根本就没有连上啊 看看吧 C#.net是怎么了
- 程序怎样被分给多个人开发?
- iframe为什么没有按照顺序执行、显示?问题请进:
但用自己写的程序发,就会有这种限制,但是记得这个程序在去年六月份的时候还是好的,难道是打了所有2003补丁的原因?