长期以来,所有的网络脚本都是使用免费的邮件服务器发送邮件,或者是自己的(我了解到的如此,恕我孤陋寡闻)。.NET 1.1已经提供了这个功能。刚才在开心的blog上看到——如何通过需要验证的邮件服务器发送邮件?真的不错。

    在此,想到大鱼用.Text构架的这个blog,现在的邮件功能还不能使用。希望大鱼看看,改进改进,呵呵。另外这个代码也可以供平常使用,一举两得。贴出代码,以免我忘记了。

//--------------------以下是 C#.net 代码--------------------

private void Page_Load(object sender, System.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"); //basic authentication
       mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "my_username_here"); //set your username here
      mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "super_secret"); //set your password here

    SmtpMail.SmtpServer = "mail.mycompany.com";  //your real server goes here
    SmtpMail.Send( mail );
}

 

相关文章:

  • 2021-06-21
  • 2021-10-02
猜你喜欢
  • 2021-12-10
  • 2022-02-02
  • 2021-07-29
  • 2022-01-31
相关资源
相似解决方案