想通过企业邮箱发邮件.代码如下
private System.Web.Mail.MailMessage myMail;
myMail = new System.Web.Mail.MailMessage();
myMail.From=strUserEmail;
myMail.To=lbl_email.Text.Trim();
myMail.Subject="无量程网站通知您:求职简历——" + lblPositionName.Text;
myMail.BodyFormat=MailFormat.Html;
myMail.Body="<p>尊敬的企业用户:</p> ";
SmtpMail.SmtpServer="发送邮件服务器";
SmtpMail.SmtpServer.Insert( 0,"发送邮件服务器");
myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "***");
myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "***"); try
{
SmtpMail.Send(myMail);
strMsg +="该企业将收到您投递简历的邮件通知。";
}
catch(Exception ex)
{
string strError=ex.Message.ToString();
}但总显示"未能访问CDO.Message对象",
我的防火墙是关闭状态,而且我也试过去掉用户名,密码,只要myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "0");
还是发不出去,我本地电脑,公司服务器都发不出去,
拜托大家多给建议.
private System.Web.Mail.MailMessage myMail;
myMail = new System.Web.Mail.MailMessage();
myMail.From=strUserEmail;
myMail.To=lbl_email.Text.Trim();
myMail.Subject="无量程网站通知您:求职简历——" + lblPositionName.Text;
myMail.BodyFormat=MailFormat.Html;
myMail.Body="<p>尊敬的企业用户:</p> ";
SmtpMail.SmtpServer="发送邮件服务器";
SmtpMail.SmtpServer.Insert( 0,"发送邮件服务器");
myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "***");
myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "***"); try
{
SmtpMail.Send(myMail);
strMsg +="该企业将收到您投递简历的邮件通知。";
}
catch(Exception ex)
{
string strError=ex.Message.ToString();
}但总显示"未能访问CDO.Message对象",
我的防火墙是关闭状态,而且我也试过去掉用户名,密码,只要myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "0");
还是发不出去,我本地电脑,公司服务器都发不出去,
拜托大家多给建议.
解决方案 »
- 再次求mvc如何获取controller
- 分享:批量上传图片
- 初学者,编写的代码,请过来人给优化下!
- 打开查询分析器,可是却被告知,"[Microsoft][ODBC SQL Server Driver][TCP/IP Sockets]Sql Server 不存在或访问被拒绝"
- 请大家说说asp.net结合xml可以做些什么?目前asp.net做什么需要应用到xml?
- Textbox 设置为Password,当从数据库取的密码之后直接副上去,不行,,有什么好办法???
- window.open
- checkboslixt用来筛选搜索结果时出错
- DataKeyField如何指定到两个字段
- 这是啥意思?
- [在线求助].Net的ASC码处理问题
- html静态网页中如何包含文件?
Then try to register cdosys.dll component:C:\WINNT\system32>regsvr32 cdosys.dll
If success, then it’s done.But if you got the following error message:DllRegisterServer in cdosys.dll failed. Return code was: 0x800704daSolution from Microsoft Support:Based on the research and experience, there are several versions of CDO, which may not be able to coexist on the same machine. For more details regarding the CDO versions, please refer to: Title: Collaboration Data Objects Roadmap URL: http://msdn.microsoft.com/library/en-us/dncdsys/html/cdo_roadmap.asp In order to resolve the issue, you can find the CDO file current registered, un-register it, and then re-register the file CDOSYS.DLL. In order to find/un-register the CDO file current registered, you may refer to the following steps: 1. Launch Regedt32.exe from “Start” -> “Run”. 2. Navigate to HKEY_CLASSES_ROOT\CDO.xxxxxx (CDO.xxxxxx represents a registry item, i.e. CDO.Address), copy down the default value of the key CLSID (i.e. {CD000110-8B95-11D1-82DB-00C04FB1625D}). 3. Navigate to HKEY_CLASSES_ROOT\CLSID\{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} (Note: {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} represents the value got in step 2.) 4. The default value of the sub-key “InprocServer32” is the path of the target file. 5. Un-register the file with the command line “Regsvr32 -u xxxxx.dll”. After un-registering the file, you can try to register the file CDOSYS.DLL again, and it should work fine. Take my local machine as an example:C:\WINNT\system32>regsvr32 -u C:\PROGRA~1\COMMON~1\MICROS~1\CDO\CDOEX.DLLNote the path of the above CDO DLL is from in step 2. C:\WINNT\system32>regsvr32 cdosys.dllThen it works fine. Source links:1. Developer fusion, http://www.developerfusion.co.uk/forums/topic-15962 2. dotnet247.com, http://www.dotnet247.com/247reference/msgs/28/141472.aspx 并且在引用中添加了c:\winnt\system32\cdosys.dll执行后还是一样的"未能访问cdo.message",请问该如何解决?
myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "用户名");
myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "密码");
myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername","用户名");
myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword","密码");
这个我也加了.还是通过不了.并且换成
myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate","0");
去掉用户名和密码的.也是发不出邮件.好郁闷.
我用outlook和foxmail都可以正常发送邮件.端口25也没被封掉.
{
try
{
MailMessage mail = new MailMessage();
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "masong_1978"); //set your username here
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "781911"); //set your password here
mail.To = txtTo.Text;
mail.From = txtFrom.Text;
mail.Subject = txtSubject.Text;
mail.Body = txtMessage.Text;
if(File1.PostedFile.FileName!="")
{
char[] de = {'\\'};
string[] AFilename = File1.PostedFile.FileName.Split(de);
string strFilename = AFilename[AFilename.Length-1]; //得到文件名
string strPath= Server.MapPath(".")+"\\Temp\\"+strFilename;
File1.PostedFile.SaveAs(strPath);
mail.Attachments.Add(new MailAttachment(strPath));
}SmtpMail.SmtpServer = txtServer.Text;//"localhost";
SmtpMail.Send(mail);
lblResult.Text = "邮件已发出!";
}
catch( Exception ex )
{
lblResult.Text = ex.ToString();
}
} }
SmtpMail.SmtpServer="127.0.0.1";
myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "***");
myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "***"); try
{
SmtpMail.Send(myMail);
strMsg +="发送成功!";
}
catch(Exception ex)
{
string strError=ex.Message.ToString();
}结果并没有捕捉到错误.并且执行到"发送成功".但我去邮箱中查看并没收到测试邮件.why?