public void ProcessNotEntryNotification(string fullName, string details, string email, string lastPaymentDate) { if (!string.IsNullOrEmpty(lastPaymentDate)) { lastPaymentDate = "Su último pago fue realizado el día " + lastPaymentDate + "."; } var entryInfo = "Su entrada en " + DateTime.Now.ToString("dd/MM/yyyy HH:mm") + " no pudo ser registrada exitosamente."; var bodyData = new System.Collections.Generic.Dictionary <string, string> { { "UserName", fullName }, { "message", details }, { "entryDateInfo", entryInfo }, { "lastPaymentDateInfo", lastPaymentDate } }; _sendEmail.SendEmail(bodyData, "AssistanceUserNotEntryTemplate", "Notificación de entrada no procesada" + fullName, new System.Collections.Generic.List <string>() { email } ); }
private void NotifyByDate() { var users = from m in _context.User where m.SendNotification select m; var sendMail = false; var message = string.Empty; foreach (var user in users) { sendMail = false; var payments = from m in _context.Payment select m; payments = payments.Where(p => p.UserId == user.UserId); if (payments.Count() > 0) { var newestPayment = payments.OrderByDescending(p => p.PaymentDate).First(); if (newestPayment.MovementTypeId > 0) { var dateMinToNotify = newestPayment.LimitUsableDate.Date.AddDays(-int.Parse(_appSettings.Value.PaymentNotificationDaysBefore)); if (_timeZone.GetCurrentDateTime(DateTime.Now).Date >= dateMinToNotify) { // se venció el tiempo de uso del ultimo pago message = "Fecha límite de uso cercana o sobrepasada. La misma es " + newestPayment.LimitUsableDate.Date.ToShortDateString() + "."; sendMail = true; } } } else//error: usuario sin pagos { message = "Usuario sin pagos."; sendMail = true; } if (sendMail) { var bodyData = new System.Collections.Generic.Dictionary <string, string> { { "UserName", user.FullName }, { "Message", message } }; _sendEmail.SendEmail(bodyData, "AssistanceTemplateFinishPayment", "Notificación por expiración de acceso", new System.Collections.Generic.List <string>() { user.Email } ); } } }
public void SendNotification(string currentUserEmail, string currentUserName, string friendEmail) { string emailBody = ""; bool isFriendMember = _queryUserByEmail.UserWithEmailExists(friendEmail); if (isFriendMember) { // do they already list current user as one of their friends? var friendUserId = _queryUserByEmail.GetUserByEmail(friendEmail).UserId; bool currentUserAlreadyFriend = _queryUserByEmail.IsUserWithEmailFriendOfUser(friendUserId, currentUserEmail); if (currentUserAlreadyFriend) { emailBody = String.Format(@"Good News! friend {0} just added you as a friend!", currentUserEmail); } else { emailBody = String.Format(@"{0} added you as a friend on PluralsightBook! Click here to add them as your friend: http://localhost:4927/QuickAddFriend.aspx?email={1}", currentUserName, currentUserEmail); } } else { emailBody = String.Format(@"{0} added you as a friend on PluralsightBook! Click here to register your own account and then add them as your friend: http://localhost:4927/QuickAddFriend.aspx?email={1}", currentUserName, currentUserEmail); } _emailSender.SendEmail(emailBody); }
public ActionResult TestEmail() { // sends a test email to confirm SMTP configuration is working _emailSender.SendEmail("*****@*****.**", "*****@*****.**", "Test Email from /TestEmail path", "This is just a test."); return(Ok("Email sent")); }
public void SendConfirmationEmail(Models.AppointmentDTO appointment) { _logger.LogInformation($"Sending email to confirm appointment: {appointment}"); string confirmUrl = $"http://*****:*****@thevetclinic.com"; string subject = "Vet Appointment Confirmation for " + appointment.PatientName; string body = String.Format("<html><body>Dear {0},<br/><p>Please click the link below to confirm {1}'s appointment for a {2} with {3} on {4}.</p><p>Thanks!</p><p><a href='{5}'>CONFIRM</a></p><p>Please call the office to reschedule if you will be unable to make it for your appointment.</p><p>Have a great day!</p></body></html>", appointment.ClientName, appointment.PatientName, appointment.AppointmentType, appointment.DoctorName, appointment.AppointmentStartDateTime.ToString(), confirmUrl); _emailSender.SendEmail(to, from, subject, body); }
public Result SendEmail(string from, string to) { var result = new Result(); if (string.IsNullOrEmpty(to)) { result.ErrorMessages.Add("Cannot send an email with an empty to address"); return(result); } emailSender.SendEmail(from, to); return(result); }
private void SendMail(string userName, string message, string email) { var bodyData = new System.Collections.Generic.Dictionary <string, string> { { "UserName", userName }, { "Title", "Aviso Importante" }, { "message", message } }; _sendEmail.SendEmail(bodyData, "AssistanceTemplate", "Notificación de Aviso" + userName, new System.Collections.Generic.List <string>() { email } ); }
public void SendNotification(string currentUserEmail, string currentUserName, string friendEmail) { string emailBody = ""; bool isFriendMember = _queryUsersByEmail.UserWithEmailExists(friendEmail); if (isFriendMember) { //This user is already a member. Now check if he is already your friend //var friendUserId = (Guid)Membership.GetUser(Membership.GetUserNameByEmail(friendEmail)).ProviderUserKey; var friendUserId = _queryUsersByEmail.GetUserByEmail(friendEmail).UserId; //bool currentUserAlreadyFriend = context.Friends.Any(f => f.UserId == friendUserId && f.EmailAddress == currentUserEmail); bool currentUserAlreadyFriend = _queryUsersByEmail.IsUserWithEmailFriendOfUser(friendUserId, currentUserEmail); if (currentUserAlreadyFriend) { //I am already in the friend list of "EmailTextBox.Text". So, you add him as a friend and let your friend know that you too have added him as your friend emailBody = String.Format(@"Good News! Your friend {0} just added you as a friend", currentUserEmail); } else { //I am not added as a friend in the friend list of "EmailTextBox.Text". So ask him to add me as a friend emailBody = String.Format(@"{0} added you as a friend. Click here to add them as your friend:http://localhost:4927/QuickAddFriend.aspx?email={1}", currentUserName, currentUserEmail); } } else { //This user is not a member emailBody = String.Format(@"{0} added you as a friend. Click here to register your own account and then add them as your friend:http://localhost:4927/QuickAddFriend.aspx?email={1}", currentUserName, currentUserEmail); } //Debug.Print("Sending Email: " + emailBody); _sendmail.SendEmail(emailBody); }
public ActionResult Contact(EmailData eM) { var message = sendEmail.SendEmail(eM); return(Json(message)); }
private void SendEmail_Execute(object sender, PopupWindowShowActionExecuteEventArgs e) { ISendEmail sendEmail = (ISendEmail)this.View.CurrentObject; sendEmail.SendEmail(EmailParams.To, EmailParams.Cc, EmailParams.Bcc, EmailParams.Subject, EmailParams.Body); }
public bool ProcessPayment(Payment payment, string userName, string userEmail) { var isEdit = false; if (payment.PaymentId > 0) { isEdit = true; } try { _context.Add(payment); _context.SaveChangesAsync(); } catch (Exception ex) { var messageError = ex.Message; _logger.LogError("Error Processing Payment. Detail: " + messageError); if (ex.InnerException != null) { _logger.LogError("Error Processing Payment. Detail: " + ex.InnerException.Message); } return(false); } try { var bodyData = new System.Collections.Generic.Dictionary <string, string> { { "UserName", userName }, { "Title", "Notificación de pago realizado." }, { "amount", payment.Amount.ToString() }, { "paymentDate", payment.PaymentDate.ToShortDateString() }, { "limitDate", payment.LimitUsableDate.ToShortDateString() }, { "quantity", payment.QuantityMovmentType.ToString() } }; switch (payment.MovementTypeId) { #region Mensual case (int)PaymentTypeEnum.Monthly: if (payment.QuantityMovmentType > 1) { bodyData.Add("type", "meses"); } else { bodyData.Add("type", "mes"); } break; #endregion #region Por asistencias case (int)PaymentTypeEnum.ByAssistances: if (payment.QuantityMovmentType > 1) { bodyData.Add("type", "asistencias"); } else { bodyData.Add("type", "asistencia"); } break; #endregion } if (isEdit) { bodyData.Add("action", "editado"); bodyData.Add("paymentId", payment.PaymentId + " "); } else { bodyData.Add("action", "registrado"); bodyData.Add("paymentId", string.Empty); } _sendEmail.SendEmail(bodyData, "PaymentTemplate", "Notificación de pago realizado", new System.Collections.Generic.List <string>() { userEmail } ); } catch (Exception ex) { var messageError = ex.Message; _logger.LogError("Error Sending email. Detail: " + messageError); if (ex.InnerException != null) { _logger.LogError("Error Sending email. Detail: " + ex.InnerException.Message); } } return(true); }
private async Task <IActionResult> ExportToExcel(List <UserReportModel> result) { string path = _env.WebRootPath; string Ruta_Publica_Excel = path + "/ReporteUsuario_" + DateTime.Now.ToString("ddMMyyyyHHmmss") + ".xlsx"; ExcelPackage Package = new ExcelPackage(new System.IO.FileInfo(Ruta_Publica_Excel)); var Hoja_1 = Package.Workbook.Worksheets.Add("Contenido_1"); /*------------------------------------------------------*/ int rowNum = 2; int originalRowNum = rowNum; Hoja_1.Cells["B" + rowNum].Value = "Nombre"; Hoja_1.Cells["C" + rowNum].Value = "Fecha Nacimiento"; Hoja_1.Cells["D" + rowNum].Value = "Fecha Ingreso"; Hoja_1.Cells["E" + rowNum].Value = "Cantidad Entradas"; Hoja_1.Cells["F" + rowNum].Value = "Fecha 1ra Asistencia"; Hoja_1.Cells["G" + rowNum].Value = "Fecha Ultima Assistencia"; Hoja_1.Cells["H" + rowNum].Value = "Tipo Pago"; Hoja_1.Cells["I" + rowNum].Value = "Medio de Pago"; Hoja_1.Cells["J" + rowNum].Value = "Cantidad Pagos"; Hoja_1.Cells["K" + rowNum].Value = "Fecha 1er Pago"; Hoja_1.Cells["L" + rowNum].Value = "Fecha Ultimo Pago"; Hoja_1.Cells["B" + rowNum + ":N" + rowNum].Style.Font.Bold = true; Hoja_1.Cells["B" + rowNum + ":N" + rowNum].Style.Font.Size = 15; foreach (UserReportModel row in result) { rowNum++; Hoja_1.Cells["B" + rowNum].Value = row.Name; Hoja_1.Cells["C" + rowNum].Value = row.BirthDate.ToString("dd/MM/yyyy"); Hoja_1.Cells["D" + rowNum].Value = ((DateTime)row.SingInDate).ToString("dd/MM/yyyy"); Hoja_1.Cells["E" + rowNum].Value = row.AssistanceCount; Hoja_1.Cells["F" + rowNum].Value = row.AssistFrom.ToString("dd/MM/yyyy"); Hoja_1.Cells["G" + rowNum].Value = row.AssistTo.ToString("dd/MM/yyyy"); Hoja_1.Cells["H" + rowNum].Value = row.paymentType; Hoja_1.Cells["I" + rowNum].Value = row.paymentMedia; Hoja_1.Cells["J" + rowNum].Value = row.PaymentCount; Hoja_1.Cells["K" + rowNum].Value = row.PaymentFrom.ToString("dd/MM/yyyy"); Hoja_1.Cells["L" + rowNum].Value = row.PaymentTo.ToString("dd/MM/yyyy"); } /*------------------------------------------------------*/ Package.Save(); //SendMail var user = await _userManager.GetUserAsync(User); var userEmail = user.Email; var userName = user.UserName; if (string.IsNullOrEmpty(userEmail)) { userEmail = _appSettings.Value.EmailConfiguration_Username; } if (string.IsNullOrEmpty(userName)) { userName = "******"; } var bodyData = new Dictionary <string, string> { { "UserName", userName }, { "Title", "Envío de reporte de usuario." }, { "message", "Descargue el archivo adjunto." } }; _sendEmail.SendEmail(bodyData, "ReportTemplate", "Reporte de movimientos de caja", new List <string>() { userEmail }, new List <string>() { Ruta_Publica_Excel } ); if ((System.IO.File.Exists(Ruta_Publica_Excel))) { System.IO.File.Delete(Ruta_Publica_Excel); } return(RedirectToAction(nameof(Index))); }
public bool SendLoginNotyfication(string userName, string destination) { SendEmail.SetProperties(userName, destination, "Gold Chat: Login Notyfication", "You have login: "******"dd:MM On HH:mm:ss") + " To Gold Chat Account."); return(SendEmail.SendEmail()); }
public async Task <IActionResult> ExportToExcel(DateTime FromDate, DateTime ToDate) { if (FromDate == DateTime.MinValue) { FromDate = _timeZone.GetCurrentDateTime(DateTime.Now).AddDays(-7); } if (ToDate == DateTime.MinValue) { ToDate = _timeZone.GetCurrentDateTime(DateTime.Now).AddDays(1); } var cashMovs = _context.CashMovement.Where(cm => cm.CashMovementDate >= FromDate && cm.CashMovementDate < ToDate); cashMovs.OrderByDescending(x => x.CashMovementDate); string path = _env.WebRootPath; string Ruta_Publica_Excel = path + "/MovimientosDeCaja_" + _timeZone.GetCurrentDateTime(DateTime.Now).ToString("ddMMyyyyHHmmss") + ".xlsx"; ExcelPackage Package = new ExcelPackage(new System.IO.FileInfo(Ruta_Publica_Excel)); var Hoja_1 = Package.Workbook.Worksheets.Add("Contenido_1"); /*------------------------------------------------------*/ int rowNum = 1; Hoja_1.Cells["B" + rowNum].Value = "Desde:"; Hoja_1.Cells["C" + rowNum].Value = FromDate.ToShortDateString(); Hoja_1.Cells["D" + rowNum].Value = "Hasta:"; Hoja_1.Cells["E" + rowNum].Value = ToDate.ToShortDateString(); /*------------------------------------------------------*/ rowNum = 2; int originalRowNum = rowNum; Hoja_1.Cells["B" + rowNum].Value = "Detalles"; Hoja_1.Cells["C" + rowNum].Value = "Tipo"; Hoja_1.Cells["D" + rowNum].Value = "Categoría"; Hoja_1.Cells["E" + rowNum].Value = "Subcategoría"; Hoja_1.Cells["F" + rowNum].Value = "Medio de Pago"; Hoja_1.Cells["G" + rowNum].Value = "Fecha"; Hoja_1.Cells["H" + rowNum].Value = "Monto"; Hoja_1.Cells["I" + rowNum].Value = "Proveedor"; Hoja_1.Cells["K" + rowNum].Value = "Saldos por Medio de pago"; Hoja_1.Cells["N" + rowNum].Value = "Total movimientos"; Hoja_1.Cells["B" + rowNum + ":N" + rowNum].Style.Font.Bold = true; Hoja_1.Cells["B" + rowNum + ":N" + rowNum].Style.Font.Size = 15; Dictionary <string, float> balances = new Dictionary <string, float>(); foreach (CashMovement row in cashMovs) { row.CashMovementType = _context.CashMovementType.Where(x => x.CashMovementTypeId == row.CashMovementTypeId).First(); row.CashCategory = _context.CashCategory.Where(x => x.CashCategoryId == row.CashCategoryId).First(); row.CashSubcategory = _context.CashSubcategory.Where(x => x.CashSubcategoryId == row.CashSubcategoryId).First(); row.PaymentMedia = _context.PaymentMedia.Where(x => x.PaymentMediaId == row.PaymentMediaId).First(); row.Supplier = _context.Supplier.Where(x => x.SupplierId == row.SupplierId).First(); rowNum++; Hoja_1.Cells["B" + rowNum].Value = row.CashMovementDetails; Hoja_1.Cells["C" + rowNum].Value = row.CashMovementType.CashMovementTypeDescription; Hoja_1.Cells["D" + rowNum].Value = row.CashCategory.CashCategoryDescription; Hoja_1.Cells["E" + rowNum].Value = row.CashSubcategory.CashSubcategoryDescription; Hoja_1.Cells["F" + rowNum].Value = row.PaymentMedia.PaymentMediaDescription; Hoja_1.Cells["G" + rowNum].Value = row.CashMovementDate.ToString("dd/MM/yyyy"); Hoja_1.Cells["H" + rowNum].Value = row.CashMovementTypeId == 1 ? row.Amount : (row.Amount * (-1)); Hoja_1.Cells["I" + rowNum].Value = row.Supplier.SupplierDescription; if (balances.ContainsKey(row.PaymentMedia.PaymentMediaDescription)) { float totalAmount = balances[row.PaymentMedia.PaymentMediaDescription] + (float)(row.CashMovementTypeId == 1 ? row.Amount : (row.Amount * (-1))); balances[row.PaymentMedia.PaymentMediaDescription] = totalAmount; } else { balances.Add(row.PaymentMedia.PaymentMediaDescription, (float)(row.CashMovementTypeId == 1 ? row.Amount : (row.Amount * (-1)))); } } if (cashMovs.Count() > 0) { //Total movs sum: Hoja_1.Cells["N" + (originalRowNum + 1)].Formula = "SUM(H" + (originalRowNum + 1) + ":H" + rowNum + ")"; //Total by paymentType int rowNumTotal = 2; foreach (string key in balances.Keys) { rowNumTotal++; Hoja_1.Cells["k" + rowNumTotal].Value = key; Hoja_1.Cells["L" + rowNumTotal].Value = balances[key]; } } /*------------------------------------------------------*/ Package.Save(); //SendMail var user = await _userManager.GetUserAsync(User); var userEmail = user.Email; var userName = user.UserName; if (string.IsNullOrEmpty(userEmail)) { userEmail = _appSettings.Value.EmailConfiguration_Username; } if (string.IsNullOrEmpty(userName)) { userName = "******"; } var bodyData = new Dictionary <string, string> { { "UserName", userName }, { "Title", "Envío de movimientos de caja." }, { "message", "Descargue el archivo adjunto." } }; _sendEmail.SendEmail(bodyData, "ReportTemplate", "Reporte de movimientos de caja", new List <string>() { userEmail }, new List <string>() { Ruta_Publica_Excel } ); try { if ((System.IO.File.Exists(Ruta_Publica_Excel))) { System.IO.File.Delete(Ruta_Publica_Excel); } } catch (Exception ex) { var messageError = ex.Message; _logger.LogError("Error Processing Payment. Detail: " + messageError); if (ex.InnerException != null) { _logger.LogError("Error Processing Payment. Detail: " + ex.InnerException.Message); } } return(RedirectToAction(nameof(Index))); }
public IActionResult ExportToExcel(DateTime FromDate, DateTime ToDate) { if (FromDate == DateTime.MinValue) { FromDate = DateTime.Now.AddDays(-7); } if (ToDate == DateTime.MinValue) { ToDate = DateTime.Now.AddDays(1); } var cashMovs = _context.CashMovement.Where(cm => cm.CashMovementDate >= FromDate && cm.CashMovementDate < ToDate); string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);//_env.WebRootPath;//Environment.GetFolderPath(Environment.SpecialFolder.Desktop); string Ruta_Publica_Excel = (path + "/MovimientosDeCaja_" + DateTime.Now.ToString("ddMMyyyyHHmmss") + ".xlsx"); ExcelPackage Package = new ExcelPackage(new System.IO.FileInfo(Ruta_Publica_Excel)); var Hoja_1 = Package.Workbook.Worksheets.Add("Contenido_1"); /*------------------------------------------------------*/ int rowNum = 1; Hoja_1.Cells["B" + rowNum].Value = "Desde:"; Hoja_1.Cells["C" + rowNum].Value = FromDate.ToShortDateString(); Hoja_1.Cells["D" + rowNum].Value = "Hasta:"; Hoja_1.Cells["E" + rowNum].Value = ToDate.ToShortDateString(); /*------------------------------------------------------*/ rowNum = 2; int originalRowNum = rowNum; Hoja_1.Cells["B" + rowNum].Value = "Detalles"; Hoja_1.Cells["C" + rowNum].Value = "Tipo"; Hoja_1.Cells["D" + rowNum].Value = "Categoría"; Hoja_1.Cells["E" + rowNum].Value = "Subcategoría"; Hoja_1.Cells["F" + rowNum].Value = "Fecha"; Hoja_1.Cells["G" + rowNum].Value = "Monto"; Hoja_1.Cells["H" + rowNum].Value = "Proveedor"; Hoja_1.Cells["B" + rowNum + ":H" + rowNum].Style.Font.Bold = true; Hoja_1.Cells["B" + rowNum + ":H" + rowNum].Style.Font.Size = 15; foreach (CashMovement row in cashMovs) { row.CashMovementType = _context.CashMovementType.Where(x => x.CashMovementTypeId == row.CashMovementTypeId).First(); row.CashCategory = _context.CashCategory.Where(x => x.CashCategoryId == row.CashCategoryId).First(); row.CashSubcategory = _context.CashSubcategory.Where(x => x.CashSubcategoryId == row.CashSubcategoryId).First(); row.Supplier = _context.Supplier.Where(x => x.SupplierId == row.SupplierId).First(); rowNum++; Hoja_1.Cells["B" + rowNum].Value = row.CashMovementDetails; Hoja_1.Cells["C" + rowNum].Value = row.CashMovementType.CashMovementTypeDescription; Hoja_1.Cells["D" + rowNum].Value = row.CashCategory.CashCategoryDescription; Hoja_1.Cells["E" + rowNum].Value = row.CashSubcategory.CashSubcategoryDescription; Hoja_1.Cells["F" + rowNum].Value = row.CashMovementDate.ToString(); Hoja_1.Cells["G" + rowNum].Value = row.CashMovementTypeId == 1 ? row.Amount : (row.Amount * (-1)); Hoja_1.Cells["H" + rowNum].Value = row.Supplier.SupplierDescription; } if (cashMovs.Count() > 0) { Hoja_1.Cells["G" + (rowNum + 1)].Formula = "SUM(G" + (originalRowNum + 1) + ":G" + rowNum + ")"; } /*------------------------------------------------------*/ Package.Save(); //SendMail var userEmail = User.FindFirst(ClaimTypes.Name).Value; var bodyData = new Dictionary <string, string> { { "UserName", "Administrador" }, { "Title", "Te mando eso!" }, { "message", "Si no te llego mala liga." } }; _sendEmail.SendEmail(bodyData, "AssistanceTemplate", "Notificación de asistencia" + userEmail, new List <string>() { userEmail }, new List <string>() { Ruta_Publica_Excel } ); if ((System.IO.File.Exists(Ruta_Publica_Excel))) { System.IO.File.Delete(Ruta_Publica_Excel); } return(RedirectToAction(nameof(Index))); }