string email = "[email protected]";
string userName = "xxx";
string password = "xxx"; Message oMsg = new MessageClass();
oMsg.From = ""; // 邮件来源
oMsg.To = email;
oMsg.Subject = "确认函"; System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("你的邮件内容");
oMsg.HTMLBody = sb.ToString();
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; //sender mail
oFields["http://schemas.microsoft.com/cdo/configuration/smtpaccountname"].Value = "[email protected]"; //email account
oFields["http://schemas.microsoft.com/cdo/configuration/sendusername"].Value = "xxx"; // 邮箱用户名
oFields["http://schemas.microsoft.com/cdo/configuration/sendpassword"].Value = "xxx"; // 邮箱密码
oFields["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"].Value = 1;
//value=0 代表Anonymous验证方式(不需要验证)
//value=1 代表Basic验证方式(使用basic (clear-text) authentication. 
//The configuration sendusername/sendpassword or postusername/postpassword fields are used to specify credentials.)
//Value=2 代表NTLM验证方式(Secure Password Authentication in Microsoft Outlook Express)
oFields["http://schemas.microsoft.com/cdo/configuration/languagecode"].Value = 0x0804;
oFields["http://schemas.microsoft.com/cdo/configuration/smtpserver"].Value = "smtp.126.com"; // 邮件服务器地址 oFields.Update();
oMsg.BodyPart.Charset="gb2312";
oMsg.HTMLBodyPart.Charset="gb2312";  oMsg.Send();
oMsg = null;