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);

        }
  • 相关阅读:
    oracle改表语句
    pr视频过渡效果
    远程桌面连接
    kill-power
    Leetcode 466.统计重复个数
    Leetcode 464.我能赢吗
    Leetcode 462.最少移动次数使数组元素相等
    Leetcode 459.重复的子字符串
    Leetcode 458.可怜的小猪
    Leetcode 457.环形数组循环
  • 原文地址:https://www.cnblogs.com/ringwang/p/991240.html
Copyright © 2011-2022 走看看