zoukankan      html  css  js  c++  java
  • 使用System.Web.Mail发送Email

    要发送E-mail必须引入命名空间System.Web.Mail,使用其中的MailMessage和SmtpMail对象,其中MailMessage用来设定E-mail的内容,而SmtpMail则负责把E-mail发出去。

        protected void Page_Load(object sender, EventArgs e)
        {
            MailMessage mail 
    = new MailMessage();
            
    //收件人地址
            mail.To = "paopao@dongfeng.net";
            
    //发件人地址
            mail.From = "paopao@dongfeng.net";
            mail.Subject 
    = "邮件标题";
            mail.Body 
    = "邮件内容";
            
    //设置需要服务器端验证
            mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate""1");
            
    //验证用户名
            mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername""用户名");
            
    //验证密码
            mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword""密码");
            
    //发送邮件的SMTP服务器地址
            SmtpMail.SmtpServer = "SMTP服务器地址";
            SmtpMail.Send(mail);
            Response.Write(
    "发送成功!");
        }
  • 相关阅读:
    寒假学习10
    寒假学习9
    寒假学习8
    寒假学期7
    寒假学习6
    寒假学习5
    寒假学习4
    Notification通知栏的使用
    Service的使用
    BroadcastReceive的使用
  • 原文地址:https://www.cnblogs.com/qixin622/p/754313.html
Copyright © 2011-2022 走看看