System.Web.Mail[1]

[入库:2006年2月23日] [更新:2007年3月24日]

本文简介:

System.Web.Mail.SmtpMail.Send
调用了内部方法: SmtpMail.CdoSysHelper.Send(message);


CdoSysHelper.Send的内部方法实现为:
if ((text2 != null) || (message.Fields.Count > 0))
      {
            object obj4 = SmtpMail.LateBoundAccessHelper.GetPropStatic(obj1, "Configuration");
            if (obj4 != null)
            {
                  if (text2 != null)
                  {
                        SmtpMail.LateBoundAccessHelper.SetPropStatic(obj4, "Fields", "http://schemas.microsoft.com/cdo/configuration/sendusing", 2);
                        SmtpMail.LateBoundAccessHelper.SetPropStatic(obj4, "Fields", "http://schemas.microsoft.com/cdo/configuration/smtpserver", text2);
                        SmtpMail.LateBoundAccessHelper.SetPropStatic(obj4, "Fields", "http://schemas.microsoft.com/cdo/configuration/smtpserverport", 0x19);
                  }
                  foreach (DictionaryEntry entry1 in message.Fields)
                  {
                        SmtpMail.LateBoundAccessHelper.SetPropStatic(obj4, "Fields", (string) entry1.Key, entry1.Value);
                  }
                  object obj5 = SmtpMail.LateBoundAccessHelper.GetPropStatic(obj4, "Fields");
                  SmtpMail.LateBoundAccessHelper.CallMethodStatic(obj5, "Update", new object[0]);
                  Marshal.ReleaseComObject(obj5);
                  Marshal.ReleaseComObject(obj4);
            }
      }

因为如下的信息:
foreach (DictionaryEntry entry1 in message.Fields)
                  {
                        SmtpMail.LateBoundAccessHelper.SetPropStatic(obj4, "Fields", (string) entry1.Key, entry1.Value);
                  }

故我们可以自己添加相关的CDO属性:
如使用需要认证的SMTP SERVER,则我们可以加入
   MailMessage myMail = new MailMessage();
   myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername",userName);
   myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword",password);
这样就达到了认证的效果.

本文关键:System.Web.Mail
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top