/// <summary> /// 发送单封邮件 /// </summary> /// <param name="email">邮件地址</param> /// <param name="subject">主题</param> /// <param name="body">内容</param> /// <param name="type">邮件类型</param> /// <returns>发送结果</returns> /// <remarks>2014-1-14 黄波 创建</remarks> public EdmResult Send(string email, string subject, string body, EmailType type) { FocusSendWebService webService = new FocusSendWebService(); FocusUser user = GetFocusUser(type); FocusEmail focusEmail = new FocusEmail(); focusEmail.Body = body; focusEmail.IsBodyHtml = true; FocusReceiver receiver = new FocusReceiver(); receiver.Email = email; try { result = webService.SendOne(user, focusEmail, subject, receiver); } catch { } return(ConvertResult(result)); }
/// <summary> /// 批量发送邮件,但发给每一个人的邮件内容都不一样 /// </summary> /// <param name="table">邮件内容</param> /// <returns>发送结果</returns> /// <remarks>2014-1-14 黄波 创建</remarks> public EdmResult BatchSend(DataTable table) { FocusUser user = GetFocusUser(EmailType.Notification); EmailSenderInfo sender = EmailSender.GetSenderByType(EmailType.Notification); FocusTask task = new FocusTask(); task.TaskName = "BatchSendPersonal:" + DateTime.Now; task.SenderEmail = sender.Email; task.SenderName = sender.Name; task.SendDate = DateTime.Now; task.Subject = ""; List <FocusEmail> emailList = new List <FocusEmail>(); FocusEmail fEmail; List <FocusReceiver> receiverList = new List <FocusReceiver>(); FocusReceiver fReceiver; foreach (DataRow dr in table.Rows) { fEmail = new FocusEmail(); fReceiver = new FocusReceiver(); fEmail.Subject = dr["subject"].ToString(); fEmail.Body = dr["body"].ToString(); emailList.Add(fEmail); fReceiver.Email = dr["email"].ToString(); receiverList.Add(fReceiver); } FocusSendWebService service = new FocusSendWebService(); try { result = service.BatchSendPersonal(user, task, emailList.ToArray(), receiverList.ToArray()); } catch { } return(ConvertResult(result)); }
/// <summary> /// 批量发送邮件 /// </summary> /// <param name="table">主题</param> /// <param name="subject">主题</param> /// <param name="body">内容</param> /// <param name="type">邮件类型</param> /// <returns>发送结果</returns> /// <remarks>2014-1-14 黄波 创建</remarks> public EdmResult BatchSend(DataTable table, string subject, string body, EmailType type) { FocusSendWebService service = new FocusSendWebService(); FocusUser user = GetFocusUser(type); EmailSenderInfo sender = EmailSender.GetSenderByType(type); FocusEmail email = new FocusEmail(); email.Body = body; email.IsBodyHtml = true; FocusTask task = new FocusTask(); task.TaskName = "BatchTask:" + DateTime.Now; task.SenderEmail = sender.Email; task.SenderName = sender.Name; task.SendDate = DateTime.Now; task.Subject = subject; List <FocusReceiver> list = new List <FocusReceiver>(); FocusReceiver receiver; foreach (DataRow dr in table.Rows) { receiver = new FocusReceiver(); receiver.Email = dr["Email"].ToString(); list.Add(receiver); } try { result = service.BatchSend(user, email, task, list.ToArray()); } catch { } return(ConvertResult(result)); }