日期:2014-05-18 浏览次数:20433 次
/// <summary> /// sha256加密函数 /// </summary> /// <param name="ss">需要加密的字符串</param> /// <returns></returns> public string getsha256(string str) { SHA256 sha = new System.Security.Cryptography.SHA256Managed(); byte[] shaByte; shaByte = sha.ComputeHash(Encoding.Default.GetBytes(str)); sha.Clear(); return Convert.ToBase64String(shaByte); }
------解决方案--------------------
/// <summary> /// 发送邮件的功能 /// 引用方式: /// </summary> public class emailHelp { /// <summary> /// 发送邮件(1-5为发件人的信息;6-10为收件人信息) /// </summary> /// <param name="SendID">发件人邮箱账号</param> /// <param name="SendPass">发件人邮箱密码</param> /// <param name="SendName">发件人名称</param> /// <param name="host">Smtp服务器</param> /// <param name="port">smtp端口</param> /// <param name="ReceiveID">接收人邮箱账号</param> /// <param name="ReceiveName">接收人姓名</param> /// <param name="Title">邮件标题</param> /// <param name="Content">邮件正文</param> /// <param name="fj">邮件附件</param> public static void SendEmail(string SendID, string SendPass, string SendName, string host, int port, string ReceiveID, string ReceiveName, string Title, string Content, string fj) { try { #region 发送邮件 SmtpClient smtp = new SmtpClient(); //实例化一个SmtpClient smtp.Port = port; smtp.DeliveryMethod = SmtpDeliveryMethod.Network; smtp.Host = host; //指定 smtp 服务器地址 smtp.UseDefaultCredentials = false; smtp.Credentials = new NetworkCredential(SendID.Trim(), SendPass); MailMessage mm = new MailMessage(); //实例化一个邮件类 mm.Priority = MailPriority.Normal; //邮件的优先级 //发件人邮箱地址 mm.From = new MailAddress(SendID.Trim(), SendName); mm.To.Add(new MailAddress(ReceiveID, ReceiveName)); //邮件标题和编码格式 mm.Subject = Title; mm.SubjectEncoding = System.Text.Encoding.UTF8; //邮件正文是否是HTML格式和编码格式 mm.IsBodyHtml = true; mm.BodyEncoding = System.Text.Encoding.UTF8; //邮件正文 mm.Body = Content; //