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");
还是发不出去,我本地电脑,公司服务器都发不出去,
拜托大家多给建议.
11 个解决方案
#1
//***引入CDO.DLL动态库
#2
但是,我按照下面这个步骤已经操作过了。
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: 0x800704da
Solution 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.DLL
Note the path of the above CDO DLL is from in step 2.
C:\WINNT\system32>regsvr32 cdosys.dll
Then 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",请问该如何解决?
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: 0x800704da
Solution 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.DLL
Note the path of the above CDO DLL is from in step 2.
C:\WINNT\system32>regsvr32 cdosys.dll
Then 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",请问该如何解决?
#3
问题是这样的
首先要在自己的机器上面架设电子邮件服务的才能
发送的出去的
首先要在自己的机器上面架设电子邮件服务的才能
发送的出去的
#4
可是我在自己机子上对默认smtp虚拟服务器配置过,在访问选项卡中身份验证选择了"匿名访问",在中继限制中设置为仅写列列表可访问,一个是127.0.0.1,一个是企业邮箱的ip,一个是本机本地ip.防火墙处于关闭状态.仍是发不出邮件,并试着加过SmtpMail.SmtpServer.Insert(0,"127.0.0.1");的代码,都发不出邮件.求救啊~
#5
帮顶。
#6
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", "密码");
myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "用户名");
myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "密码");
#7
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","密码");
这个我也加了.还是通过不了.并且换成
myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate","0");
去掉用户名和密码的.也是发不出邮件.好郁闷.
我用outlook和foxmail都可以正常发送邮件.端口25也没被封掉.
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也没被封掉.
#8
高手们出来。
#9
{
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();
}
}
}
#10
To masong_1978(我不当好人了!) :我在发送邮件时没加附件,所以不需要附件部分的代码,其他的和你的设置一样。SmtpMail.SmtpServer = txtServer.Text;//"localhost";表示你用的应该是本机的邮件服务器?那如何配置的呢?还有你添加什么动态库了么?我又试了一遍还是没发出去。
#11
我用了winwebmail软件.
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?
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?
#1
//***引入CDO.DLL动态库
#2
但是,我按照下面这个步骤已经操作过了。
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: 0x800704da
Solution 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.DLL
Note the path of the above CDO DLL is from in step 2.
C:\WINNT\system32>regsvr32 cdosys.dll
Then 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",请问该如何解决?
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: 0x800704da
Solution 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.DLL
Note the path of the above CDO DLL is from in step 2.
C:\WINNT\system32>regsvr32 cdosys.dll
Then 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",请问该如何解决?
#3
问题是这样的
首先要在自己的机器上面架设电子邮件服务的才能
发送的出去的
首先要在自己的机器上面架设电子邮件服务的才能
发送的出去的
#4
可是我在自己机子上对默认smtp虚拟服务器配置过,在访问选项卡中身份验证选择了"匿名访问",在中继限制中设置为仅写列列表可访问,一个是127.0.0.1,一个是企业邮箱的ip,一个是本机本地ip.防火墙处于关闭状态.仍是发不出邮件,并试着加过SmtpMail.SmtpServer.Insert(0,"127.0.0.1");的代码,都发不出邮件.求救啊~
#5
帮顶。
#6
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", "密码");
myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "用户名");
myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "密码");
#7
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","密码");
这个我也加了.还是通过不了.并且换成
myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate","0");
去掉用户名和密码的.也是发不出邮件.好郁闷.
我用outlook和foxmail都可以正常发送邮件.端口25也没被封掉.
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也没被封掉.
#8
高手们出来。
#9
{
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();
}
}
}
#10
To masong_1978(我不当好人了!) :我在发送邮件时没加附件,所以不需要附件部分的代码,其他的和你的设置一样。SmtpMail.SmtpServer = txtServer.Text;//"localhost";表示你用的应该是本机的邮件服务器?那如何配置的呢?还有你添加什么动态库了么?我又试了一遍还是没发出去。
#11
我用了winwebmail软件.
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?
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?