public bool SendMail(MailSettingModel mail, UserViewModel user) { var settings = _uof.SettingsRepository.GetAll(r => r.IsActive && r.TenantId == user.Company.TenantId && r.CompanyId == user.CompanyId).ToList(); if (settings != null) { if (settings.Any(r => r.Key == "SMTP_From") && !string.IsNullOrEmpty(settings.Find(r => r.Key == "SMTP_From").Value)) { mail.SMTP_From = settings.Find(r => r.Key == "SMTP_From")?.Value; } if (settings.Any(r => r.Key == "SMTP_Host") && !string.IsNullOrEmpty(settings.Find(r => r.Key == "SMTP_Host").Value)) { mail.SMTP_Host = settings.Find(r => r.Key == "SMTP_Host")?.Value; } if (settings.Any(r => r.Key == "SMTP_Port") && !string.IsNullOrEmpty(settings.Find(r => r.Key == "SMTP_Port").Value)) { mail.SMTP_Port = Int32.Parse(settings.Find(r => r.Key == "SMTP_Port").Value); } if (settings.Any(r => r.Key == "SMTP_Username") && !string.IsNullOrEmpty(settings.Find(r => r.Key == "SMTP_Username").Value)) { mail.SMTP_Username = settings.Find(r => r.Key == "SMTP_Username").Value; } if (settings.Any(r => r.Key == "SMTP_Password") && !string.IsNullOrEmpty(settings.Find(r => r.Key == "SMTP_Password").Value)) { mail.SMTP_Password = settings.Find(r => r.Key == "SMTP_Password").Value; } } return(EMailService.SendEmail(mail)); }
/// <summary> /// Link to page /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void gvUsers_RowCommand(object sender, GridViewCommandEventArgs e) { if ("Sort".Equals(e.CommandName)) { return; } if (e.CommandArgument.ToString() != "") { int id = Convert.ToInt32(e.CommandArgument); if (e.CommandName == "Select") { EditUser(id); } if (e.CommandName == "DeleteUser") { User user = UserService.GetUser(id); if (user != null) { UserService.DeleteUser(user); LoadUsers(); } } if (e.CommandName == "ChangeStatus") { User user = UserService.GetUser(id); if (user != null) { user.IsDisabled = !user.IsDisabled; UserService.UpdateUser(user); LoadUsers(); } } if (e.CommandName == "ResetPassword") { User user = UserService.GetUser(id); string newPassword = UserService.NewPassword(user); user.IsApproved = false; user.IsDisabled = false; UserService.SaveUser(user); EMailService.SendEmail("Sterling Scholar password reset request", UserService.FormatTemplate(System.Web.HttpContext.Current.Server.MapPath("~/") + "/assets/PasswordResetTemplate.html", user), user.EMail, UserService.AdminEmailAddress, null); } if (e.CommandName == "Unlock") { User user = UserService.GetUser(id); UserService.UnlockUser(user); EMailService.SendEmail("Sterling Scholar Account unlock request", UserService.FormatTemplate(System.Web.HttpContext.Current.Server.MapPath("~/") + "/assets/UnlockTemplate.html", user), user.EMail, UserService.AdminEmailAddress, null); } //if (e.CommandName.Equals("ViewPortfolio")) //{ // StringBuilder sb = new StringBuilder(); // sb.Append("<script language=JavaScript id='openit'>"); // sb.Append("window.open('../ReportView.aspx?report=profile&id=" + e.CommandArgument + "', '', '');"); // sb.Append("</script>"); // if (!ClientScript.IsStartupScriptRegistered("openit")) // { // ClientScript.RegisterStartupScript(this.GetType(), "openit", sb.ToString()); // } //} } }
public ActionResult SendEmail(string EMailTo, string EMailCc, string subject, string EmailText, string DocumentFullPath, int ReflID) { var myList = new List <string>(); myList.Add(DocumentFullPath); _mailService.SendEmail(EmailText, EMailTo, EMailCc, subject, myList.ToArray()); EmailRecordStorage(EMailTo, EMailCc, subject, EmailText, myList, ReflID); IMRRFAReferral _IMRRFAReferrals = new IMRRFAReferral(); _IMRRFAReferrals.IMRResponseDate = System.DateTime.Now; _IMRRFAReferrals.RFAReferralID = ReflID; _iIMRService.updateIMRRFAReferralByValues(Mapper.Map <MMCService.IMRService.IMRRFAReferral>(_IMRRFAReferrals)); _iPreparationService.updateProcessLevel(ReflID, GlobalConst.ProcessLevel.IMRDecision); return(Json(GlobalConst.Message.EmailSendMessage)); }
public ActionResult EmailSendMultipleDoc(EmailMultipleAttachment objEmailAttached) { var myList = new List <string>(); if (objEmailAttached.AttachmentForEmailArray != null) { foreach (var multipath in objEmailAttached.AttachmentForEmailArray) { myList.Add(multipath.AttachmentLink); } } var myListReferralIDorFileID = GetRFAReferralFileIDOrReferralID(objEmailAttached.popUpName); _mailService.SendEmail(objEmailAttached.SendEmailText, objEmailAttached.SendEMailTo, objEmailAttached.SendEMailCc, objEmailAttached.Sendsubject, myList.ToArray()); EmailRecordStorage(objEmailAttached.SendEMailTo, objEmailAttached.SendEMailCc, objEmailAttached.Sendsubject, objEmailAttached.SendEmailText, myList, objEmailAttached.popUpName, objEmailAttached.rflID, myListReferralIDorFileID); return(Json(GlobalConst.Message.EmailSendMessage, GlobalConst.ContentTypes.TextHtml)); }
public async Task <IActionResult> RegisterVoter(InVoterRegisterDTO inVoterRegisterDto) { if (inVoterRegisterDto.Password != inVoterRegisterDto.ConfirmPassword) { return(BadRequest()); } var g = Guid.NewGuid(); var username = Convert.ToBase64String(g.ToByteArray()).Replace("=", string.Empty) .Replace("+", String.Empty).Replace("/", String.Empty); var userDetail = new UserDetail() { CNP = inVoterRegisterDto.CNP, EncryptedPrivateKey = inVoterRegisterDto.EncryptedPrivateKey, PublicKey = inVoterRegisterDto.PublicKey, FirstName = inVoterRegisterDto.FirstName, LastName = inVoterRegisterDto.LastName, Number = inVoterRegisterDto.Number, Series = inVoterRegisterDto.Series }; var user = new User() { Email = inVoterRegisterDto.Email, PhoneNumber = inVoterRegisterDto.Phone, }; user.UserDetail = userDetail; user.UserName = username; var result = await _userManager.CreateAsync(user, inVoterRegisterDto.Password); if (!result.Succeeded) { return(Unauthorized()); } var emailToken = await _userManager.GenerateEmailConfirmationTokenAsync(user); var emailHtml = await System.IO.File.ReadAllTextAsync("wwwroot/confirmEmailToken.html"); emailHtml = emailHtml.Replace("{BaseUrl}", "http://localhost:8080/#/verify") .Replace("{EmailToken}", emailToken) .Replace("{UserName}", username); var emailSuccess = await EMailService.SendEmail(inVoterRegisterDto.Email, "EVoting Username and Confirm Email", emailHtml); return(Ok(new BaseResponseDTO <string>() { Success = true, Message = "User registered successfully! Please also verify your email.", Result = username })); }
private void SavePortfolio() { UserInput input = null; Portfolio p = PortfolioService.GetPortfolio(PortfolioId); if (null != p) { input = UserService.GetUserProfile(p.User.Id); } else { input = new UserInput(); } input.FullName = txtFullName.Text; input.EMail = txtEmail.Text; input.Comment = txtComment.Text; input.Phone = txtPhone.Text; input.Role = RoleType.Nominee; input.School = GetSchool(); input.Category = CategoryService.GetCategory(input.School.Area.Region, ddlCategory.SelectedValue); MembershipCreateStatus status = UserService.AddNewUser(input); if (status == MembershipCreateStatus.Success) { User user = UserService.GetUser(input.EMail); Portfolio portfolio = PortfolioService.GetPortfolioByUser(user); portfolio.Parents = txtParents.Text; portfolio.Address = txtAddress.Text; portfolio.City = txtCity.Text; portfolio.Zip = txtZip.Text; portfolio.State = ddlState.SelectedValue; portfolio.Sex = (Sexes)Enum.Parse(typeof(Sexes), ddlGender.SelectedValue.ToString()); if (ddlStatus.Enabled) { portfolio.Status = (Status)Enum.Parse(typeof(Status), ddlStatus.SelectedValue); } PortfolioService.Save(portfolio); SaveTestScores(portfolio); if (input.Id <= 0) { EMailService.SendEmail("Sterling Scholar Registration Request", UserService.FormatTemplate(System.Web.HttpContext.Current.Server.MapPath("~/") + "/assets/NewUserTemplate.html", user), user.EMail, UserService.AdminEmailAddress, null); } PortfolioId = portfolio.Id; lnkPicture.Visible = true; lnkTransUpload.Visible = true; } }
public ActionResult EmailNotificationDoc(IEnumerable <RFAReferralFile> RFAReferralFile, string EMailTo, string EMailCc, string subject, string EmailText, int RFAReferralID, string documentPath) { var myList = new List <string>(); string path = _storageService.getReferralLetterStorage(Server.MapPath(System.Configuration.ConfigurationManager.AppSettings[GlobalConst.VirtualDirectoryPath.VirtualPath].ToString()), RFAReferralFile.First().RFAReferralID); //foreach (RFAReferralFile __rfaReferralFiledetail in RFAReferralFile) //{ // if (__rfaReferralFiledetail.IsChecked) // { // myList.Add(path + GlobalConst.ConstantChar.DoubleBackSlash + __rfaReferralFiledetail.RFAReferralFileName); // } //} if (documentPath != null) { Tuple <string, string> t = DownloadPrintDocumnent(RFAReferralFile); myList.Add(t.Item1); } _mailService.SendEmail(EmailText, EMailTo, EMailCc, subject, myList.ToArray()); EmailRecordStorage(EMailTo, EMailCc, subject, EmailText, myList, RFAReferralID); return(Json(GlobalConst.Message.EmailSendMessage, GlobalConst.ContentTypes.TextHtml)); }