vs.net2003里添加邮件发件人身份验证

MailMessage msg = new MailMessage();
   msg.To = mailTo;  // assumes strEmail was set
   msg.Cc = cc;
   msg.From = mailFrom ;
   msg.Subject = subject;
   msg.Priority = priority;
   msg.BodyFormat = format;
   msg.Body = body;
   msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //表示基本验证
   msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", Globals.SmtpUsername); //发件人的Email登录用户名
   msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", Globals.SmtpPassword); //发件人的Email登录密码

   SmtpMail.SmtpServer = Globals.SmtpServer;

   try
   {
    SmtpMail.Send(msg);
    bret = true;
   }
   catch
   {
    bret = false;
   }

原文地址:https://www.cnblogs.com/linn/p/825777.html