zoukankan      html  css  js  c++  java
  • asp.net邮件发送

        这里的邮件发送是指运行程序的服务器上已经安装了邮件服务器。如果用其他的邮件服务器不知道能不能发送。
    还有这里用的发送邮件类是 System.Net.Mail.MailMessage,而不是System.Web.Mail .MailMessage类,因为前面的类是新版本的类,我也鼓励大家用新类。
    代码如下:
     /// <summary>
        
    /// 发送邮件给供应商
        
    /// </summary>
        
    /// <param name="form"></param>
        
    /// <param name="to"></param>
        
    /// <param name="subject"></param>
        
    /// <param name="body"></param>
        
    /// <returns></returns>

        public void SendEmailToSupplier(string from, string to, string subject, string body)
        
    {          

            System.Net.Mail.MailMessage msg 
    = new System.Net.Mail.MailMessage();
            msg.From 
    = new System.Net.Mail.MailAddress(from ,"新邮件");
            msg.To.Add(to);
            msg.Subject 
    = subject;
            msg.Body 
    = body;
            msg.BodyEncoding 
    = System.Text.Encoding.GetEncoding("GB2312");
            msg.Priority 
    = System.Net.Mail.MailPriority.High;
            System.Net.Mail.SmtpClient cliect 
    = new System.Net.Mail.SmtpClient("邮件服务器的IP");
            cliect.Credentials 
    = new System.Net.NetworkCredential("mail_box""123456");
            cliect.Send(msg);

        }
  • 相关阅读:
    设计模式:生产者消费者模式
    图解SSH原理
    监听Google Player下载并获取包名等信息
    android targetSdkVersion>=26收不到广播的处理
    ant property file刷新不及时
    maven的pom文件报错: must be "pom" but is "jar"
    AJAX其实就是一个异步网络请求
    String、StringBuffer、StringBuilder的区别
    Properties、ResourceBundle
    JavaWeb--Listener
  • 原文地址:https://www.cnblogs.com/ringwang/p/991240.html
Copyright © 2011-2022 走看看