我编写了个发送邮件的程序:发送时出现如下错误:
发送失败:System.Web.HttpException: 未能访问“CDO.Message”对象
请问是怎么回事.
发送失败:System.Web.HttpException: 未能访问“CDO.Message”对象
请问是怎么回事.
解决方案 »
- winfrom中如何显示网页的其中一个部分
- 触摸屏 大点触控-不太懂,请指请.
- 关于datagridview如何更新的问题,执行后有问题,高手解答!!!!
- 关于delphi 数据类型转 C#的问题
- Remoting問題
- 下拉列表怎么和DataSet进行绑定
- 【求救SOS】C# EndRead IO异常,与 asyneccallback 异常
- 请问那种在统计当前光标在文本框里处于第几行第几列的效果是怎么做的?谢谢!
- C#splitcontainer控件问题
- 高分讨教:如何获得已经安装在系统里的软件列表,就是打开控制面板中的添加/删除程序所看到的
- messagebox确定后,怎么连主窗口都关了?
- 关于软件多版本的问题,很多人都可能遇到的。枚举也有机制上的问题?
MailMessage MyMsg = new MailMessage();
MyMsg.From = tbFrom.Text;
MyMsg.To = tbTo.Text;
MyMsg.Subject = tbSubject.Text;
MyMsg.Priority = (MailPriority)ddlPriority.SelectedIndex;
MyMsg.BodyFormat= (MailFormat)ddlBodyFormat.SelectedIndex;
MyMsg.Body = tbBody.Text;
MyMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); MyMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername","[email protected]"); MyMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "53344521binbin");
//如果有附件则上传
HttpPostedFile hpfFile = AttachFile.PostedFile;
if(hpfFile.FileName!="")
{
//有附件,则上传到Temp目录中
//取得文件名(不含路径)
char[] de = {'\\'};
string[] AFilename = hpfFile.FileName.Split(de);
string strFilename = AFilename[AFilename.Length-1];
string strPath = Server.MapPath(".")+"\\Temp\\"+strFilename;
hpfFile.SaveAs(strPath);
//添加附件
MyMsg.Attachments.Add(new MailAttachment(strPath));
} try
{
//发送
SmtpMail.Send(MyMsg);
lblShowMsg.Text ="发送成功";
tbTo.Text = "";
tbSubject.Text = "";
tbBody.Text = "";
ddlPriority.SelectedIndex = 1;
ddlBodyFormat.SelectedIndex = 0;
}
catch(Exception ee)
{
lblShowMsg.Text = "发送失败:"+ee.ToString();
}
}