通过需要验证的邮件服务器发送email

通过需要验证的邮件服务器发送email
原文地址:http://blog.joycode.com/joy/posts/11405.aspx

void Page_Load(object sender, EventArgs e) {

       MailMessage mail = new MailMessage();
       mail.To = "me@mycompany.com";
       mail.From = "you@yourcompany.com";
       mail.Subject = "this is a test email.";
       mail.Body = "Some text goes here";
       mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); // 设置验证
       mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "my_username_here"); // 设置用户名
      mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "super_secret"); // 设置密码

    SmtpMail.SmtpServer = "mail.mycompany.com";  // 设置smtp服务器
    SmtpMail.Send( mail );
}

posted on 2004-01-23 09:27  良子  阅读(1787)  评论(2)    收藏  举报

导航