通过需要身份验证的smtp服务器发邮件的问题???!!!!
一个程序需要发邮件,可是我们的smtp服务器不让匿名,于是去csdn查到了这个,
编译没有问题,可是发送的时候出现了这个错误,兄弟们看看这是怎么了????
错误:
System.Runtime.InteropServices.COMException (0x80040211): The message could not be sent to the SMTP server. The transport error code was 0x80040217. The server response was not available at CDO.MessageClass.Send() at OnlineService.testl.Button1_Click(Object sender, EventArgs e) in d:\web\onlineservice\testl.aspx.cs:line 74
http://www.csdn.net/Develop/Read_Article.asp?Id=14850
//在reference中添加CDO for Windows 2000
using CDO;
public void SendEmail()
{
try
{
Configuration conf=new ConfigurationClass();
conf.Fields[CdoConfiguration.cdoSendUsingMethod].Value=CdoSendUsing.cdoSendUsingPort;
conf.Fields[CdoConfiguration.cdoSMTPServer].Value="smtp.netease.com";
conf.Fields[CdoConfiguration.cdoSMTPServerPort].Value=25;
conf.Fields[CdoConfiguration.cdoSMTPAccountName].Value="hydnoahark";
conf.Fields[CdoConfiguration.cdoSendUserReplyEmailAddress].Value="\"hydnoahark\" <hydnoahark@netease.com>";
conf.Fields[CdoConfiguration.cdoSendEmailAddress].Value="\"hydnoahark\" <hydnoahark@netease.com>";
conf.Fields[CdoConfiguration.cdoSMTPAuthenticate].Value=CdoProtocolsAuthentication.cdoBasic;
conf.Fields[CdoConfiguration.cdoSendUserName].Value="hydnoahark";
conf.Fields[CdoConfiguration.cdoSendPassword].Value="xxx";
conf.Fields.Update();
MessageClass msg=new MessageClass();
msg.Configuration=conf;
msg.To="hydnoahsark@sina.com";
msg.Subject="Hello";
msg.TextBody="It's test";
msg.From="hydnoahark@netease.com";
msg.Send();
}
catch(System.Runtime.InteropServices.COMException e)
{
MessageBox.Show(e.ToString());
}
return;
}
浙公网安备 33010602011771号