public async Task <TranStatus> SendMail_Sales(SendMailModel model) { using (mailRepository = new MailRepository()) { return(await mailRepository.SendMail_Sales(model)); } }
public ActionResult SendMail(SendMailModel m) { string dirFullPath = GetServerParth(AppSetting.SENDMAIL_UPLOAD_DIR); List <string> attachFiles = new List <string>(); if (m.添付1 != null) { attachFiles.Add(dirFullPath + "\\" + "1" + "\\" + m.添付1); } if (m.添付2 != null) { attachFiles.Add(dirFullPath + "\\" + "2" + "\\" + m.添付2); } if (m.添付3 != null) { attachFiles.Add(dirFullPath + "\\" + "3" + "\\" + m.添付3); } m.SendMailToUser(m.宛先, m.件名, m.内容, attachFiles); //メール送信が完了した後、添付ファイルのフォルダーを削除する var dirinfo = new DirectoryInfo(dirFullPath); if (dirinfo.Exists) { Directory.Delete(dirFullPath, true); } return(Json(new { result = "success" })); }
public async Task <TranStatus> SendMail_Sales(SendMailModel model) { using (var connection = new SqlConnection(ConnectionString)) { await connection.OpenAsync(); TranStatus transaction = new TranStatus(); DynamicParameters parameter = new DynamicParameters(); parameter.Add("@UserName", model.UsernameEmail); parameter.Add("@Token", dbType: DbType.String, direction: ParameterDirection.Output, size: 50); parameter.Add("@UserIdentity", dbType: DbType.Int32, direction: ParameterDirection.Output); parameter.Add("@User", dbType: DbType.String, direction: ParameterDirection.Output, size: 50); parameter.Add("@Message", dbType: DbType.String, direction: ParameterDirection.Output, size: 500); parameter.Add("@Code", dbType: DbType.Int32, direction: ParameterDirection.Output); await connection.QueryAsync("SendMail_Sales", parameter, commandType : CommandType.StoredProcedure); transaction.returnMessage = parameter.Get <string>("@Message"); transaction.code = parameter.Get <int>("@Code"); if (transaction.code == 0) { transaction.Token = parameter.Get <string>("@Token"); transaction.User = parameter.Get <string>("@User"); transaction.UserIdentity = parameter.Get <int>("@UserIdentity"); } return(transaction); } }
/// <summary> /// Send Mail via SMTP method /// </summary> /// <param name="model">SendMailModel contents all required params for sending mail</param> public static async Task <bool> SendMail(SendMailModel model) { try { MailMessage mail = new MailMessage(); mail.From = new MailAddress(SMTP_LOGIN); mail.To.Add(new MailAddress(model.MailTo)); mail.Subject = model.Subject; mail.IsBodyHtml = true; mail.Body = model.Message; if (!string.IsNullOrEmpty(model.AttachFile)) { mail.Attachments.Add(new Attachment(model.AttachFile)); } SmtpClient client = new SmtpClient(SMTP_SERVER, SMTP_PORT); client.EnableSsl = true; client.UseDefaultCredentials = false; client.Credentials = new NetworkCredential(SMTP_LOGIN, SMTP_PASSWORD); client.DeliveryMethod = SmtpDeliveryMethod.Network; await client.SendMailAsync(mail); mail.Dispose(); return(true); } catch (Exception e) { Console.WriteLine(string.Format(@"Error message: {0}", e.Message)); return(false); } }
public bool SendMail(SendMailModel sendmail) { try { MailMessage msj = new MailMessage(); SmtpClient sc = new SmtpClient(); sc.Credentials = new System.Net.NetworkCredential("*****@*****.**", "Mg199349"); msj.To.Add("*****@*****.**"); msj.From = new MailAddress("*****@*****.**", "dukkan.com.tr", Encoding.UTF8); msj.Subject = sendmail.NameSurname + " iletişim sayfasından gönderdi"; msj.SubjectEncoding = Encoding.UTF8; msj.BodyEncoding = Encoding.UTF8; msj.IsBodyHtml = true; msj.Body = sendmail.Message; sc.EnableSsl = false; sc.Port = 587; sc.Host = " 5.2.85.56"; sc.Send(msj); msj.Dispose(); } catch (Exception) { return(false); } return(true); }
public ActionResult UploadFile() { HttpContext.Response.ContentType = "text/plain"; //Commonのプロパティ・メソッドを使用 SendMailModel m = (SendMailModel)Session[SessionVar.SHARED_SEND_MAIL_INFO]; var index = HttpContext.Request["index"]; HttpPostedFileBase file = HttpContext.Request.Files[0]; string filename = file.FileName.Split(Path.DirectorySeparatorChar).Last(); //string dirFullPath = HttpContext.Server.MapPath(ConfigurationManager.AppSettings["SendMailUploadDir"] + "\\" + userid + "\\" + index); string dirFullPath = CreateDirPath(AppKey.KEY_SENDMAIL_UPLOAD_DIR, index, true); Directory.CreateDirectory(dirFullPath); //旧ファイルを削除 DirectoryInfo dirInfo = new DirectoryInfo(dirFullPath); dirInfo.GetFiles().ToList().ForEach(x => x.Delete()); string pathToSave = dirFullPath + "\\" + filename; file.SaveAs(pathToSave); return(Json(new { result = "uploadfinish", filename = filename, index = index })); }
/// <summary> /// Metoda wysyłająca mail do listy adresatów /// </summary> /// <param name="mailModel"></param> /// <returns></returns> public IList <string> SendMail(SendMailModel mailModel) { try { string mailServer = GetMailServer(mailModel.Server); int mailPort = GetMailPort(mailModel.Server); // Utworzenie nowego klienta mailowego SmtpClient mailClient = new SmtpClient(mailServer, mailPort); mailClient.EnableSsl = true; mailClient.Credentials = new System.Net.NetworkCredential(mailModel.Sender, mailModel.Password); // Lista adresów na które nie udało się wysłać maila IList <string> results = new List <string>(); // Pętla wysyłająca mail do każdego z odbiorców foreach (var recipient in mailModel.Recipients) { try { // Utworzenie nowej wiadomości i jej wysłanie MailMessage newMessage = new MailMessage(mailModel.Sender, recipient, mailModel.Subject, mailModel.Message); mailClient.Send(newMessage); } catch (Exception e) { results.Add(recipient); } } return(results); } catch (Exception e) { return(mailModel.Recipients); } }
public ActionResult SendMail(SendMailModel model) { try { _mailer.SendEmail(model.Subject, model.Body, model.EmailAddress, _config.CompanyName); ViewBag.IsPopupAlert = true; ViewBag.AlertOptions = new AlertOptions { AlertType = EAlertType.Success, Message = Dictionary.Success, OtherMessage = "Your email was sent!" }; } catch (Exception e) { ViewBag.IsPopupAlert = true; ViewBag.AlertOptions = new AlertOptions { AlertType = EAlertType.Fail, Message = Dictionary.Error, OtherMessage = e.Message }; } return(View("Index")); }
public ActionResult Forgot_Password(Forgot_PasswordModel model) { try { if (ModelState.IsValid) { var trainer = db.Trainers.Where(i => i.Email_ID == model.Email).FirstOrDefault(); if (trainer != null) { trainer.Password = GeneratePasswordModel.GeneratePassword(3, 3, 3); var gym = db.GYMs.Where(i => i.ID == trainer.GYM_ID).FirstOrDefault(); SendMailModel.Forgate_Password(trainer.Password, trainer.First_Name + " " + trainer.Last_Name, trainer.Email_ID, gym.Name); TempData["Success"] = "Please check your registerd mailId for a new password"; db.SaveChanges(); } else { TempData["Error"] = "MailId is not registered"; return(View()); } } else { TempData["Error"] = "Please Fill All Required Details.!"; return(View()); } return(RedirectToAction("Login", "Login")); } catch (Exception ex) { return(RedirectToAction("Contact", "Home")); } }
public void sendDocMail(SendMailModel model, int?headId = null, string contractorName = null) { var order = _dbcontext.Orders.Where(o => o.Id == model.OrderId).AsNoTracking().FirstOrDefault(); if (order == null) { throw new NotFoundException(); } var emails = new List <string>(); headId = headId ?? order.Head; contractorName = ((contractorName ?? order.Contractor) ?? "").ToUpper().Trim(); if (headId.HasValue) { emails = _dbcontext.HeadStroyUsers.Where(o => o.id == headId.Value && o.Email != null && o.Email.Length > 0).Select(o => o.Email).AsNoTracking().ToList <string>(); } var Enemails = _dbcontext.MainEnginiers.Where(o => o.Email != null && o.Email.Length > 0).Select(o => o.Email).AsNoTracking().ToList <string>(); if (Enemails.Count > 0) { emails.AddRange(Enemails); } var contractor = _dbcontext.Kontragents.Where(o => o.name.ToUpper().Trim() == contractorName).AsNoTracking().FirstOrDefault(); List <FileAttachment> files = null; if (model.Ids != null) { files = _dbcontext.OrderFiles.Where(f => model.Ids.Contains(f.Id)).Select(f => new FileAttachment() { FilePath = Path.Combine(_filePath, order.Id.ToString(), f.RepFileName), FileName = f.Filename }).ToList <FileAttachment>(); } else { files = _dbcontext.OrderFiles.Where(f => f.OrderId == model.OrderId).Select(f => new FileAttachment() { FilePath = Path.Combine(_filePath, order.Id.ToString(), f.RepFileName), FileName = f.Filename }).ToList <FileAttachment>(); } if (contractor != null && (contractor.email ?? "").Trim().Length > 0) { emails.Add(contractor.email); } if (files.Count > 0 && emails.Count > 0) { string mess = _sendMailService.SendMail("*****@*****.**", string.Join(", ", emails.ToArray()), "Предписания", "Отправитель: " + _authService.GetUserInfoModel().FullName, files); if (mess.Length != 0) { throw new SendEmailException("Ошибка отправки."); } } }
void EmailSendInBackground(object MailInf) { SendMailDO sendmailDO = new SendMailDO(); SendMailModel sendModel = new SendMailModel(); MailInformation MailInform = (MailInformation)MailInf; try { //MailInform.CustomerEmailAddress = "*****@*****.**"; //MailInform.CustomerEmailAddress = "*****@*****.**"; string ErrorMessage = ""; if (MailInform.MailProperties.EmailSender(MailInform.MailProperties.UserName, MailInform.CustomerEmailAddress, MailInform.Subject, MailInform.EmailText, true, 0, ref ErrorMessage)) { sendModel.Status = true; sendModel.Error = string.Empty; Insert(sendModel, MailInform, sendmailDO); Console.WriteLine("Deposite Number : " + MailInform.DepositeNumber + " Message send to : " + MailInform.CustomerEmailAddress + " , Success"); } else { sendModel.Status = false; sendModel.Error = ErrorMessage; Insert(sendModel, MailInform, sendmailDO); Console.WriteLine("Deposite Number : " + MailInform.DepositeNumber + " Message Dont send to : " + MailInform.CustomerEmailAddress + " , Error : " + ErrorMessage); } } catch (Exception exp) { LogRegister("EmailSendInBackground", exp.Message); } }
public Task sendMail(SendMailModel model) { return(Task.Run(() => { sendDocMail(model); })); }
public Task <bool> SendEmailAsync(SendMailModel message) { Dictionary <SystemInfo, string> systemSetting = GetSystemSettings; try { SmtpClient SmtpServer = new SmtpClient(systemSetting[SystemInfo.NotificationMailServer], int.Parse(systemSetting[SystemInfo.NotificationEmailPort])); MailMessage mail = new MailMessage(); mail.From = new MailAddress(systemSetting[SystemInfo.NotificationEmail], systemSetting[SystemInfo.NotificationEmailName]); mail.To.Add(message.ToEmailAddress); mail.Subject = message.Subject; mail.IsBodyHtml = true; mail.Body = message.Body; SmtpServer.UseDefaultCredentials = true; SmtpServer.Credentials = new NetworkCredential(systemSetting[SystemInfo.NotificationEmail], Decrypt(systemSetting[SystemInfo.NotificationEmailPassword])); SmtpServer.EnableSsl = ((systemSetting[SystemInfo.NotificationEmailSSL] == "true") ? true : false); SmtpServer.Send(mail); mail.Dispose(); SaveTxtLog($"{DebugCodes.Success}: Email send to {message.ToEmailAddress}"); return(Task.FromResult(result: true)); } catch (Exception e) { SaveTxtLog($"Email {DebugCodes.Exception}: Error Sending Email {e.ToString()}"); return(Task.FromResult(result: false)); } }
public ActionResult SetFinalStatus(int id) { try { DissertationViewModel dissertation = Dissertation.GetDissertationById(id); dissertation.SaveStatus(); Certificate cert = new Certificate(); cert.StudentId = dissertation.StudentId; cert.SubjectId = dissertation.SubjectId; int certId = cert.Save(); var user = UserManager.FindById(dissertation.StudentId); UserManager.AddToRole(user.Id, "Teacher"); var callbackUrl = Url.Action("Certificates", "Teacher", new { certId = certId }, protocol: Request.Url.Scheme); string email = dissertation.Student.Email; string body = string.Format("Dear {0} {1}, Your research was approved by administrator:</br> Follow the <a href='{2}'>link</a> to generate a certificate", dissertation.Student.Name, dissertation.Student.SurName, callbackUrl); string subject = "SortIt.Research approved"; SendMailModel.SendMail(email, body, subject); return(Json("Research approved")); } catch (Exception ex) { return(Json("Fail!", JsonRequestBehavior.AllowGet)); } }
public String Post(Object o) { SendMailModel newMailData = (SendMailModel)o; try { //I decided to use the RestClient library here to show that there are multiple ways to complete this project. //It seems that there is also a package for this as well. var client = new RestClient(Environment.GetEnvironmentVariable("SENDGRID_URI")); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", Environment.GetEnvironmentVariable("SENDGRID_API_KEY")); request.AddHeader("Content-Type", "application/json"); request.AddJsonBody(newMailData); var response = client.Post(request); if (response.StatusCode != System.Net.HttpStatusCode.OK) { throw new Exception("error with URI / AUTH"); } return(response.StatusCode.ToString()); //again I would of liked to use a better error code system but with a better layout out of the project it could be done } catch (Exception e) { return(e.Message); //could add dynamic error messages. Did not spend the time to perfect the erroring system as it could take //some time and not needed to show success of the project } }
//string title, string msg, MailEntity mail = null /// <summary> /// 发送邮件 /// </summary> /// <param name="title"></param> /// <param name="msg"></param> /// <param name="mail"></param> /// <returns></returns> public async Task <bool> SendMail([FromBody] SendMailModel model) { try { if (model.MailInfo == null) { model.MailInfo = await GetMailInfo(); } var message = new MimeMessage(); message.From.Add(new MailboxAddress(model.MailInfo.MailFrom, model.MailInfo.MailFrom)); foreach (var mailTo in model.MailInfo.MailTo.Replace(";", ";").Replace(",", ";").Replace(",", ";").Split(';')) { message.To.Add(new MailboxAddress(mailTo, mailTo)); } message.Subject = string.Format(model.Title); message.Body = new TextPart("html") { Text = model.Content }; using (var client = new MailKit.Net.Smtp.SmtpClient()) { client.Connect(model.MailInfo.MailHost, 465, true); client.Authenticate(model.MailInfo.MailFrom, model.MailInfo.MailPwd); client.Send(message); client.Disconnect(true); } return(true); } catch (System.Exception) { return(false); } }
public async Task <ActionResult> sendEmail(string uname) { UserModel um = db.Umodel.Single(u => u.Username == uname); SendMailModel sm = new SendMailModel(); if (um != null) { string pw = passGen(); var message = await EMailTemplate("RecoverPW"); message = message.Replace("@ViewBag.Name", CultureInfo.CurrentCulture.TextInfo.ToTitleCase(um.Username)); message = message.Replace("@ViewBag.Pass", CultureInfo.CurrentCulture.TextInfo.ToTitleCase(pw)); await MessageServices.SendEmail(um.Email, "Project base", message); @ViewBag.Error = "Nerror"; @ViewBag.Uname = uname; sm.RecoverCode = pw; } else { @ViewBag.Error = "error"; } return(View("~/Views/Login/ForgotPassword.cshtml", sm)); }
public Task <TranStatus> SendMail(SendMailModel model) { using (mailRepository = new MailRepository()) { return(mailRepository.SendMail(model)); } }
public IActionResult Index(SendMailModel model) { var err = ""; var ret = _emailSender.SendEmail(model.Email, model.FromAlias, model.Subject, model.Content, out err); ModelState.AddModelError("", err); return(View()); }
public async Task <IActionResult> SendMail([FromBody] SendMailModel request) { var hosts = HttpContext.Request.Host; _Apiloger.LogDebug($"{hosts.Host}正在请求发送邮件 端口是 {hosts.Port},{hosts.Value}"); await MailHelp.SendMailAsync(request.Smtpserver, request.UserName, request.Pwd, request.ToMail, request.Subj, request.Bodys, request.FromMail); return(Ok(new SucessModel())); }
public void SendMail(Progress work) { var Teacher = UserProfile.GetTeacherByStudentLessonId(work.StudentId, work.LessonId); string link = string.Format("<div class='row' style='border:1px solid #808080' align='center'><p style='color:red'>New homework uploaded</p>" + "<a href='http://{0}/Files/homeworks/{1}'>{1}</a>" + "<input type='button' value='Approve' onclick='window.location.href='http://{0}/Teacher/Works''></div>", Request.Url.Authority, work.Attachement); SendMailModel.SendMail(Teacher.Email, link, "SortIt.Work published"); }
public string resetPassword(string email) { string resultStr = "test"; CommFunction cf = new CommFunction(); SendMailModel model = new SendMailModel(); bool a = cf.SendMail(model); return(resultStr); }
public void MailSender(int categoryId, int subject) { var users = UserProfile.GetUserByInterest(categoryId); var currentUser = new UserProfile(User.Identity.GetUserId()); var callbackUrl = Url.Action("SendRequestTeacher", "Manage", new { tId = User.Identity.GetUserId(), subId = subject }, protocol: Request.Url.Scheme); foreach (var user in users) { SendMailModel.SendMail(user.Email, string.Format("Dear {0} {1}, <br> We have new student matching your account. Student name {2} {3}", user.Name, user.SurName, currentUser.Name, currentUser.SurName), string.Format("SortIt.Interest matching for {0} {1}", currentUser.Name, currentUser.SurName)); } }
public async Task <bool> SendRecoveryCodeMessage(string receiver, string activationCode) { var message = new SendMailModel { MailTo = receiver, Subject = "[SIGMA] Recovery", Message = $"Ваш код воостановления пароля {activationCode}" }; return(await SendMail(message)); }
public async Task <bool> SendRequest(string receiver, string text) { var message = new SendMailModel { MailTo = receiver, Subject = "[Заявка на покупку]", Message = text }; return(await SendMail(message)); }
public async Task <bool> SendActivationMessage(string receiver, string activationKey) { var message = new SendMailModel { MailTo = receiver, Subject = "[SIGMA] Activation", Message = $"Ваш активационный код {activationKey}" }; return(await SendMail(message)); }
/// <summary> /// 寄信 /// </summary> /// <param name="mailEntity"></param> public void SendMail(SendMailModel mailEntity) { try { string sendMailFrom = string.IsNullOrEmpty(mailEntity.SendMailFrom) ? m_MailVO.SendEmail : mailEntity.SendMailFrom; m_MailService.SendMail(sendMailFrom, mailEntity.SendMailTo, mailEntity.SendMailTitle, mailEntity.SendMailContent); } catch (Exception ex) { m_Log.Error(ex); } }
public async Task <IActionResult> PostMail([FromBody] SendMailModel model) { var user = await _dbContext.GetCurrentUserAsync(User); if (user == null) { return(NotFound()); } var result = await _emailSender.SendEmailFailedTransactionAsync(user.Email, model.Body); return(Ok()); }
public ActionResult SendMail() { var roles = this.Db.Roles.ToList(); var events = this.Events.GetUpcomingEvents(); var model = new SendMailModel { Roles = roles, UpcomingEvents = events }; return(View("SendMail", model)); }
public ActionResult <string> SendMail([FromBody] SendMailModel model) { //this.mailService.SendMail(model); //if (this.mailService.SendMail(model)) //{ // return "1"; //} //else //{ // return "0"; //} return("cos"); }