C#发送邮件
2009-11-30 17:42
246 查看
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Net.Mail; using VehicleManage.Model; using VehicleManage.DAL; namespace VehicleManage.BLL { public static class SendEmails { private static MileageService mService = new MileageService(); private static SuperspeedService sService = new SuperspeedService(); private static FireDownBodyService fdbService = new FireDownBodyService(); /// <summary> /// 发送邮件 /// </summary> /// <param name="toname">收件人名称</param> /// <param name="toemail">收件人邮件地址</param> /// <param name="smtpclient">伺服器</param> /// <param name="fromname">发件人名称</param> /// <param name="fromemail">发件人邮件地址</param> /// <param name="password">发件人邮箱密码</param> /// <param name="subject">邮件标题</param> /// <param name="body">邮件主体</param> /// <returns></returns> public static bool SendEmailForGetpass(string toname, string toemail, string smtpclient, string fromname, string fromemail, string password, string subject, string body) { try { MailAddress from = new MailAddress(fromemail, fromname);//发件人 MailAddress to = new MailAddress(toemail, toname);//收件人 MailMessage message = new MailMessage(from, to); message.Subject = subject; message.Body = body; message.Priority = MailPriority.High; message.IsBodyHtml = true; SmtpClient client = new SmtpClient(smtpclient);//伺服器,如"smtp.163.com" client.Credentials = new System.Net.NetworkCredential(fromemail, password); client.Send(message); return true; } catch(Exception e) { return false; } } } }
相关文章推荐
- c#.net smtp 发送邮件
- c# 邮件发送 发送人带昵称
- 使用C#发送邮件
- C# 发送邮件
- C#编程实现发送邮件的方法(可添加附件)
- C#简单邮件发送
- c#发送邮件之System.Net.Mail方法
- C# 发送邮件
- C#System.Net.Mail采用简单邮件传输协议发送邮件
- c#.net 下的邮件发送(含附件)
- C# - MailSender 邮件发送组件源代码 (支持ESMTP, 附件)
- C#邮件发送
- C#使用smtp发送邮件
- C# 发送邮件代码
- c# 邮件发送通用类
- 用C#.net发送邮件
- C#发送邮件
- C#封装发送邮件SendMail函数
- C#通过Outlook发送邮件
- C#中如何利用Gmail账户发送邮件