try
{
CDO.Message oMsg = new CDO.Message();
 
oMsg.From = "[email protected]";
oMsg.To =  "[email protected]";
oMsg.Subject = "MailTest";
oMsg.HTMLBody = "<html><body>Test</body></html>";
CDO.IConfiguration iConfg = oMsg.Configuration;
ADODB.Fields oFields = iConfg.Fields;

oFields["http://schemas.microsoft.com/cdo/configuration/sendusing"].Value=2;
oFields["http://schemas.microsoft.com/cdo/configuration/sendemailaddress"].Value="[email protected]"; //sender mail
oFields["http://schemas.microsoft.com/cdo/configuration/smtpaccountname"].Value="[email protected]"; //email account
oFields["http://schemas.microsoft.com/cdo/configuration/sendusername"].Value="liuya617";
oFields["http://schemas.microsoft.com/cdo/configuration/sendpassword"].Value="邮件密码";
oFields["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"].Value=1;
oFields["http://schemas.microsoft.com/cdo/configuration/languagecode"].Value=0x0804;
oFields["http://schemas.microsoft.com/cdo/configuration/smtpserver"].Value="smtp.sohu.com"; oFields.Update();
oMsg.BodyPart.Charset="gb2312";
oMsg.HTMLBodyPart.Charset="gb2312";  oMsg.Send();
oMsg = null;
}
catch (Exception ex)
{
string FilePath = @"d:\错误1.txt";
StreamWriter fs = File.CreateText(FilePath);
fs.Write (DateTime.Now.ToString()+" 发送邮件产生如下错误:"+ex.Message);
fs.Close();
Console.Write(ex.Message);
//throw e;
}