public JsonResult DelSendEmail() { long id = CommonHelper.GetPostValue("id").ToLong(-1L); if (id <= 0) { return(Json(new { ErrorCode = "E001", ErrorMessage = "参数缺失!" })); } T_BG_Email email = _bgEmailService.Get(id); if (email == null) { return(Json(new { ErrorCode = "E002", ErrorMessage = "未发现该邮件!" })); } if (email.IsDel == 1) { return(Json(new { ErrorCode = "E000", ErrorMessage = "该邮件已经被删除!" })); } email.IsDel = 1; if (_bgEmailService.Update(email)) { return(Json(new { ErrorCode = "E000", ErrorMessage = "邮件删除成功!" })); } else { return(Json(new { ErrorCode = "E004", ErrorMessage = "邮件删除失败!" })); } }
public bool Update(T_BG_Email email) { try { return(_bgEmailRepository.Update(email)); } catch (Exception) { return(false); } }
public long Add(T_BG_Email email) { try { return(_bgEmailRepository.Add(email)); } catch (Exception) { return(-1L); } }
public ActionResult EmailMessage() { long emailId = CommonHelper.GetPostValue("MailId").ToLong(-1L); if (emailId < 0) { var url = DomainUrlHelper.EmailPath + "/Menu/Error?errorCode=404&errorMessage=" + HttpUtility.UrlEncode("未发现该邮件!"); return(Redirect(url)); } T_BG_Email email = _bgEmailService.Get(emailId); if (email == null) { var url = DomainUrlHelper.EmailPath + "/Menu/Error?errorCode=404&errorMessage=" + HttpUtility.UrlEncode("未查询到该邮件!"); return(Redirect(url)); } return(View(email)); }
public JsonResult SendEmail() { string users = CommonHelper.GetPostValue("usernames"); string title = CommonHelper.GetPostValue("title"); string content = CommonHelper.GetPostValue("content"); //string sendEmail = CommonHelper.GetPostValue("sendEmail"); string fileurl = CommonHelper.GetPostValue("fileurl"); string fileorgname = CommonHelper.GetPostValue("fileorgname"); string fileext = CommonHelper.GetPostValue("fileext"); title = HttpUtility.UrlDecode(title); content = HttpUtility.UrlDecode(content); fileurl = HttpUtility.UrlDecode(fileurl); fileorgname = HttpUtility.UrlDecode(fileorgname); if (string.IsNullOrEmpty(users)) { return(Json(new { ErrorCode = "E001", ErrorMessage = "參數錯誤!" })); } string[] recieverUsers = users.Split(';'); if (recieverUsers.Length <= 0) { return(Json(new { ErrorCode = "E001", ErrorMessage = "參數数量錯誤!" })); } T_BG_Email email = new T_BG_Email(); email.SendUserId = LoginHelper.UserId; email.SendUserName = LoginHelper.UserName; email.Title = title; email.Context = content; email.AddTime = DateTime.Now; email.FileUrl = fileurl; email.FileName = fileorgname; email.FileExt = fileext; email.IsDel = 0; email.Lvl = 0; email.Recievers = users; long result = _bgEmailService.Add(email); if (result <= 0) { return(Json(new { ErrorCode = "E001", ErrorMessage = "邮件信息添加失败!" })); } List <T_BG_EmailReciever> emailRecieverList = recieverUsers.Select(user => new T_BG_EmailReciever { EmailId = result, State = 0, RevieverUserId = user.ToLong(-1L) }).ToList(); bool reslt = _bgEmailRecieverService.BatchAdd(emailRecieverList); if (reslt) { return(Json(new { ErrorCode = "E000", ErrorMessage = "邮件信息添加成功!" })); } else { return(Json(new { ErrorCode = "E002", ErrorMessage = "邮件发送人添加失败!" })); } #region 发送邮件 //MailMessage message = new MailMessage(); // message.From = new MailAddress("*****@*****.**","MAX QUILL"); // string[] emailString = users.Split(';'); // if (emailString.Length > 0) // { // foreach (var address in emailString) // { // message.To.Add(address); // } // } // message.Subject = title; // if (content != null) message.Body = content; // message.IsBodyHtml = true; // Attachment data = new Attachment(fileurl, MediaTypeNames.Application.Octet); // ContentDisposition disposition = data.ContentDisposition; // disposition.CreationDate = System.IO.File.GetCreationTime(fileurl); // disposition.ModificationDate = System.IO.File.GetLastWriteTime(fileurl); // disposition.ReadDate = System.IO.File.GetLastAccessTime(fileurl); // SmtpClient client = new SmtpClient("smtp.qq.com") // { // EnableSsl = true, // UseDefaultCredentials = false, // DeliveryMethod = SmtpDeliveryMethod.Network, // Credentials = new System.Net.NetworkCredential("*****@*****.**", "naapvvgtiwhlfhgd") // }; // try // { // client.Send(message); // } // catch (Exception ex) // { // return Json(new { ErrorCode = "E001", ErrorMessage = "郵件發送失敗!" }); // } #endregion }