用CDO发送邮件,如果用内部邮件服务器,发送成功,对方收不到,如果用外部邮件服务器,就与服务器的传输连接失败。
CDO.Message oMsg = new CDO.Message();
//oMsg.From = FromTextBox.Text ;
oMsg.To = "neil.zhang@corp.elong.com";
oMsg.Subject = "test";
oMsg.HTMLBody = "TEST";
oMsg.CC = "";
oMsg.BCC = "";
string UserName;
string emailFrom;
string Password = "*******";
UserName = "";
emailFrom = "";
oMsg.From = emailFrom;
CDO.IConfiguration iConfg;
ADODB.Fields oFields;
iConfg = oMsg.Configuration;
oFields = iConfg.Fields;
oFields["http://schemas.microsoft.com/cdo/configuration/sendusing"].Value = 2;
oFields["http://schemas.microsoft.com/cdo/configuration/sendemailaddress"].Value = emailFrom;
oFields["http://schemas.microsoft.com/cdo/configuration/smtpuserreplyemailaddress"].Value = emailFrom;
oFields["http://schemas.microsoft.com/cdo/configuration/smtpaccountname"].Value = UserName;
oFields["http://schemas.microsoft.com/cdo/configuration/sendusername"].Value = UserName;
oFields["http://schemas.microsoft.com/cdo/configuration/sendpassword"].Value = Password;
oFields["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"].Value = 1;
oFields["http://schemas.microsoft.com/cdo/configuration/smtpserver"].Value = "smtp.163.com"; //"127.0.0.1"
oFields.Update();