diff --git a/Mail.cs b/Mail.cs deleted file mode 100644 index d235787..0000000 --- a/Mail.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Web; -using System.Net.Mail; - -/// -/// 发送邮件 -/// -namespace Basic.Tools -{ - public class Mail - { - /// - /// 发送邮件(smtp服务器/发送邮箱/邮箱密码/接收邮箱/发件人名称/邮件标题/邮件内容) - /// - /// - /// - /// - /// - /// - /// - /// - /// - public static bool Send(string _Host, string _from, string _pwd, string _tomail, string _senderName, string _Subject, string _Body) - { - bool Result = false; - try - { - //创建smtpclient对象 - System.Net.Mail.SmtpClient client = new SmtpClient(); - client.Host = _Host;//163的smtp服务器是 smtp.163.com - client.UseDefaultCredentials = false; - client.Credentials = new System.Net.NetworkCredential(_from, _pwd); - - client.DeliveryMethod = SmtpDeliveryMethod.Network; - System.Text.Encoding encoding = System.Text.Encoding.UTF8; - MailAddress mailfrom = new MailAddress(_from, _senderName, encoding);//发件人邮箱地址,名称,编码UTF8 - MailAddress mailto = new MailAddress(_tomail, "A", encoding);//收件人邮箱地址,名称,编码UTF8 - //创建mailMessage对象 - System.Net.Mail.MailMessage message = new MailMessage(mailfrom, mailto); - message.Subject = _Subject; - //正文默认格式为html - message.Body = _Body; - message.IsBodyHtml = true; - message.BodyEncoding = encoding; - message.SubjectEncoding = encoding; - //message.HeadersEncoding = encoding; - client.Send(message); - Result = true; - } - catch (Exception ex) - { - string e = ex.Message.ToString(); - Result = false; - } - return Result; - } - } -} \ No newline at end of file