Exemplo n.º 1
0
        private void sendResultEmailWithSchool(string name, string email, string selectedschool, string otherschools)
        {
            SimpleAES           aes          = new SimpleAES();
            EmailManager        emailManager = new EmailManager();
            EmailTemplateHelper eth          = new EmailTemplateHelper();
            string token = aes.EncryptToBase64String(email);
            string url   = "http://www.CareerThesaurus.com/TakeTest/TestReport/" + token;
            string body  = eth.GetTemplate("testresultswithschool");

            body = body.Replace("{{name}}", name);
            body = body.Replace("{{url}}", url);

            dynamic selected = JObject.Parse(selectedschool);
            dynamic other    = JArray.Parse(otherschools);

            body = body.Replace("{{schoolname}}", (string)selected["name"]);
            body = body.Replace("{{schoollogo}}", (string)selected["logo"]);
            body = body.Replace("{{schoolurl}}", (string)selected["url"]);
            string str = "<table><tr>";

            foreach (dynamic item in other)
            {
                if (item["name"] != selected["name"])
                {
                    //str += "<td><a href='" + item["url"] + "' ><img src='" + item["logo"] + "' alt='School logo' title='similar school'></a></td>";
                    str += "<td><a style='margin:0;' href='" + item["url"] + "' ><img src='" + item["logo"] + "' alt='' ></a><a style='padding-right:10px;' href='" + item["url"] + "' >" + item["name"] + "</a></td>";
                }
            }
            str += "</tr></table>";
            body = body.Replace("{{otherschools}}", str);

            emailManager.SendMail("*****@*****.**", "CareerThesaurus", email, "Your Career Test Results", body);
        }
Exemplo n.º 2
0
        async Task IEmailSender.SendGridEmailAsync(string emailAdd, string subject, string message, string organisation, string firstname, string template)
        {
            //var apiKey = "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";
            //new code

            string domain = "https://ncribstaging.azurewebsites.net";

            EmailTemplateHelper EmailHelper = new EmailTemplateHelper();

            var body = EmailHelper.GetTemplate(template).Replace("#FirstName", firstname).Replace("#ResetLink", message).Replace("#HostDomain", domain).Replace("#Organisation", organisation);

            //string

            var client = new SendGridClient(apiKey);
            var msg    = new SendGridMessage()
            {
                From             = new EmailAddress("*****@*****.**", "iBROKA"),
                Subject          = "Set Up Your Account on iBROKA.",
                PlainTextContent = "You have been registered on iBROKA platform. Kindly use the link below to create your account.",
                HtmlContent      = body
            };

            msg.AddTo(new EmailAddress(emailAdd, emailAdd));
            await client.SendEmailAsync(msg);

            //var response =
        }
Exemplo n.º 3
0
        public async Task <string> SendTestEmailAsync(int userId, EmailOutgoingSettings outgoingSettings)
        {
            await _privilegesManager.Demand(userId, InstanceAdminPrivileges.ManageInstanceSettings);

            VerifyOutgoingSettings(outgoingSettings);

            var currentUser = await _userRepository.GetUserAsync(userId);

            if (string.IsNullOrWhiteSpace(currentUser.Email))
            {
                throw new ConflictException("Your user profile does not include an email address. Please add one to receive a test email.", ErrorCodes.UserHasNoEmail);
            }

            var config = await GetEmailConfigAsync(outgoingSettings, currentUser);

            _emailHelper.Initialize(config);

            string body = EmailTemplateHelper.GetSendTestEmailTemplate(_websiteAddressService.GetWebsiteAddress());

            try
            {
                _emailHelper.SendEmail(currentUser.Email, TestEmailSubject, body);

                return(currentUser.Email);
            }
            catch (EmailException ex)
            {
                throw new BadRequestException(ex.Message, ex.ErrorCode);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 发送邮件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button17_Click(object sender, EventArgs e)
        {
            #region
            //MailAddress from = new MailAddress("*****@*****.**");
            //string messageTo = "*****@*****.**";
            //string messageSubject = "测试邮件";
            //string body = "测试邮件内容";
            //Send(from, messageTo, messageSubject, body, "");
            #endregion

            NameValueCollection values = new NameValueCollection();
            values.Add("name", "WUWEI");
            values.Add("start", "2017-09-20");
            values.Add("end", "2018-09-30");
            values.Add("points", "10000");
            string      template = EmailTemplateHelper.ConstructTemplate("../EmailTemplate.txt", values);
            EMailHelper helper   = new EMailHelper();
            helper.MailSmtpServer    = "smtp.aliyun.com";
            helper.MailCredential    = "*****@*****.**";
            helper.MailCredentialPwd = "wuwei038177";
            string mailFrom    = "*****@*****.**";
            string mailTo      = "[email protected];";
            string mailSubject = "模板邮件";
            string mailCC      = "[email protected];";
            string result;
            helper.SendSmtpMail(mailFrom, mailTo, mailSubject, template, "", "", mailCC, out result);
        }
        public static BasicResponse resetUserPasswordEmailImplementation(ResetPasswordEmailRequest request)
        {
            if (String.IsNullOrWhiteSpace(request.email))
            {
                return(new BasicResponse {
                    message = "Please enter an email.", status = 601, success = false
                });
            }

            using (var db = new UniversalGymEntities())
            {
                var user = db.Users.SingleOrDefault(f => f.Email == request.email);
                if (user == null)
                {
                    return(new BasicResponse {
                        message = "User not found.", status = 404, success = false
                    });
                }

                var forgotPasswordBody = String.Format("Someone forgot a password :/ -- {0}", request.email);
                EmailNoTemplateHelper.SendEmail("User forgot password", "*****@*****.**", forgotPasswordBody);

                user.CurrentToken = Guid.NewGuid().ToString();
                db.SaveChanges();

                var link = Constants.PedalWebUrl + "user.html#/resetPassword/" + user.UserId + "/" + user.CurrentToken;;
                EmailTemplateHelper.SendEmail("Reset Password Link - Pedal", request.email, link, user.FirstName, "reset_password.html");

                return(new BasicResponse {
                    message = "User email sent successfully", status = 3, success = true
                });
            }
        }
Exemplo n.º 6
0
        public async Task SendMailToAdministrator(string AdministratorEmail, string Password)
        {
            var    AdministratorFirstName      = db.RequestForDemo.Where(x => x.AdministratorEmail == AdministratorEmail).Select(x => x.AdministratorFirstName).FirstOrDefault();
            var    OrganizationFullName        = db.RequestForDemo.Where(x => x.AdministratorEmail == AdministratorEmail).Select(x => x.OrganizationFullName).FirstOrDefault();
            var    OrganizationShortName       = db.RequestForDemo.Where(x => x.AdministratorEmail == AdministratorEmail).Select(x => x.OrganizationShortName).FirstOrDefault();
            var    GetAdministratorPhoneNumber = db.RequestForDemo.Where(x => x.AdministratorEmail == AdministratorEmail).Select(x => x.AdministratorPhoneNumber).FirstOrDefault();
            string Subject = "Techspecialist - ProcureEase App";
            string Body    = new EmailTemplateHelper().GetTemplateContent("AdministratorSignUpTemplate");

            try
            {
                var         clientUrl          = Request.UrlReferrer.ToString();
                string      newTemplateContent = string.Format(Body, clientUrl, AdministratorFirstName, OrganizationFullName, Password);
                Message     message            = new Message(AdministratorEmail, Subject, newTemplateContent);
                EmailHelper emailHelper        = new EmailHelper();
                await emailHelper.AddEmailToQueue(message);
            }
            catch (NullReferenceException)
            {
                var         backendUrl         = System.Web.HttpContext.Current.Request.Url.Host;
                string      newTemplateContent = string.Format(Body, backendUrl, AdministratorFirstName, OrganizationFullName, Password);
                Message     message            = new Message(AdministratorEmail, Subject, newTemplateContent);
                EmailHelper emailHelper        = new EmailHelper();
                await emailHelper.AddEmailToQueue(message);
            }
        }
        public async Task <ActionResult> SendForgotPasswordEmailNotification(string emailAddress)
        {
            DIBZ.Common.Model.ApplicationUser appUser = new DIBZ.Common.Model.ApplicationUser();
            var authLogic = LogicContext.Create <AuthLogic>();
            var result    = authLogic.GetApplicationUserByEmail(emailAddress);

            if (result != null)
            {
                EmailTemplateHelper   templates             = new EmailTemplateHelper();
                EmailTemplateResponse emailTemplateResponse = new EmailTemplateResponse();
                DIBZ.Common.Model.EmailNotification email   = new DIBZ.Common.Model.EmailNotification();
                var emailTemplateLogic = LogicContext.Create <EmailTemplateLogic>();

                emailTemplateResponse = await emailTemplateLogic.GetEmailTemplate(EmailType.Email, EmailContentType.ForgotPassword);

                templates.AddParam(DIBZ.Common.Model.Contants.AppUserNickName, result.NickName);
                templates.AddParam(DIBZ.Common.Model.Contants.ForgotPassword, string.Format("<a href='{0}'>Here</a>", string.Concat(Request.Url.AbsoluteUri.Substring(0, Request.Url.AbsoluteUri.LastIndexOf("/") + 1), "ChangePassword?id=" + result.Id)));
                templates.AddParam(DIBZ.Common.Model.Contants.UrlContactUs, string.Format("<a href='{0}'>link</a>", hostName + "/Dashboard/ContactUs"));
                var emailBody = templates.FillTemplate(emailTemplateResponse.Body);

                //save email data in table
                await emailTemplateLogic.SaveEmailNotification(result.Email, emailTemplateResponse.Title, emailBody, EmailType.Email, Priority.High);

                EmailHelper.Email(result.Email, emailTemplateResponse.Title, emailBody);
                return(Json(new { IsSuccess = true }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(new { IsSuccess = false, fail = "some thing wrong" }, JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 8
0
        public ActionResult getStudentResponses(Student pStudent)
        {
            try
            {
                StudentClient tableStorage = new StudentClient();
                tableStorage.Add(pStudent);
                //email to student
                string emailBody = EmailTemplateHelper.GetTemplate("StudentEmail");
                emailBody = string.Format(emailBody, pStudent.FirstName);
                EmailHelper.SendEmail(pStudent.Email, "*****@*****.**", "Your Registration Follow up", emailBody, true);
                //email to student's parent
                string emailBody2 = EmailTemplateHelper.GetTemplate("Parent_InitiatedByStudent");
                emailBody2 = string.Format(emailBody2, pStudent.FirstParentFirstName, pStudent.FirstName);
                EmailHelper.SendEmail(pStudent.FirstParentEmail, "*****@*****.**", "Following up on behalf of " + pStudent.FirstName, emailBody2, true);

                //if second parent's info was filled out, send email to second parent
                if (pStudent.SecondParentEmail != null)
                {
                    string emailBody3 = EmailTemplateHelper.GetTemplate("Parent_InitiatedByStudent");
                    emailBody3 = string.Format(emailBody3, pStudent.SecondParentFirstName, pStudent.FirstName);
                    EmailHelper.SendEmail(pStudent.SecondParentEmail, "*****@*****.**", "Following up on behalf of " + pStudent.FirstName, emailBody3, true);
                }
                return(Content(JsonConvert.SerializeObject(new { }), "application/json"));
            }
            catch (Exception ex)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.NotFound, ex.Message));
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// 发送测试邮件
        /// </summary>
        /// <returns></returns>
        public static bool Send_Demo(string title, string to_user, NameValueCollection col)
        {
            /** col示例
             * NameValueCollection myCol = new NameValueCollection();
             * myCol.Add("ename", "litdev");
             * myCol.Add("link", "http://www.google.com");
             */
            string server_path = "~/App_Data/mailtemplate/demo.html";

            if (!IOHelper.FileExists(server_path))
            {
                return(false);
            }
            string      templetpath = IOHelper.GetMapPath(server_path);
            EmailHelper email       = new EmailHelper();

            email.enableSsl   = WebSite.EmailEnableSsl;
            email.host        = WebSite.EmailHost;
            email.isbodyHtml  = true;
            email.mailFrom    = WebSite.EmailFrom;
            email.mailPwd     = WebSite.EmailPwd;
            email.mailSubject = title;
            email.mailToArray = to_user.Split(',');
            email.port        = WebSite.EmailPort;
            email.mailBody    = EmailTemplateHelper.BulidByFile(templetpath, col);
            return(email.Send());
        }
        private void OfficeDocumentExpiryJob(EmailService emailService)
        {
            var expiryDate = DateTime.Today.AddDays(10);

            var officeDocumentDetails = from od in UnitOfWork.OfficeDocDetailsRepository.Get()
                                        join dt in UnitOfWork.DocumentTypeRepository.Get() on od.DocumentId equals dt.DocumentId
                                        where od.DocExpiryDate < expiryDate
                                        select new OfficeDocDetailsViewModel()
            {
                DocumentName  = dt.DocumentName,
                DocIssueDate  = od.DocIssueDate,
                DocExpiryDate = od.DocExpiryDate
            };

            if (officeDocumentDetails != null)
            {
                string strBody = EmailTemplateHelper.OfficeDocumentDetails(officeDocumentDetails)
                                 .Replace("[APPLICATIONLINK]", "https://aris-amt.com");

                emailService.Send(strManagerMails, "", "Office Document Expiry Reminder", strBody);
            }
            else
            {
                Console.WriteLine("No mails to send");
            }
        }
        private void ComapanyDocumentExpiryJob(EmailService emailService)
        {
            var expiryDate = DateTime.Today.AddDays(10);

            var companyDocumentDetails = from cd in UnitOfWork.CompanyRepository.Get()
                                         join cf in UnitOfWork.CompanyFileUploadsRepository.Get() on cd.CompanyId equals cf.CompanyId
                                         join dt in UnitOfWork.DocumentTypeRepository.Get() on cf.DocumentId equals dt.DocumentId
                                         where cf.CompanyExpiry < expiryDate
                                         select new CompanyViewModel()
            {
                CompanyName   = cd.CompanyName + "-" + cd.CompanyLocation,
                DocumentName  = dt.DocumentName,
                CompanyExpiry = cf.CompanyExpiry
            };

            if (companyDocumentDetails != null)
            {
                string strBody = EmailTemplateHelper.CompanyDocumentDetails(companyDocumentDetails)
                                 .Replace("[APPLICATIONLINK]", "https://aris-amt.com");

                emailService.Send(strManagerMails, "", "Company Document Expiry Reminder", strBody);
            }
            else
            {
                Console.WriteLine("No mails to send");
            }
        }
        private void SendPasswordChangeEmail(string email)
        {
            EmailManager        emailManager = new EmailManager();
            EmailTemplateHelper eth          = new EmailTemplateHelper();
            string body = eth.GetTemplate("passwordchanged");

            emailManager.SendMail("*****@*****.**", "CareerThesaurus", email, "Account Notification - Password Changed", body);
        }
        private void SendCongratulationsEmailToStudent(string email, string name)
        {
            EmailManager        emailManager = new EmailManager();
            EmailTemplateHelper eth          = new EmailTemplateHelper();
            string body = eth.GetTemplate("studentreg");

            body = body.Replace("{{name}}", name);
            emailManager.SendMail("*****@*****.**", "CareerThesaurus", email, "You're Registered -- W00t!", body);
        }
Exemplo n.º 14
0
        // private functions
        private void SendCongratulationsEmailToCounselor(string email, string name)
        {
            EmailManager        emailManager = new EmailManager();
            EmailTemplateHelper eth          = new EmailTemplateHelper();
            string body = eth.GetTemplate("counselorreg");

            body = body.Replace("{{name}}", name);
            emailManager.SendMail("*****@*****.**", "CareerThesaurus", email, "Your CareerThesaurus Account Registration", body);
        }
Exemplo n.º 15
0
        private void SendUpdateEmailToAdmin(string email, string name)
        {
            EmailManager        emailManager = new EmailManager();
            EmailTemplateHelper eth          = new EmailTemplateHelper();
            string body = eth.GetTemplate("counseloraccept");

            body = body.Replace("{{counselor}}", name);
            emailManager.SendMail("*****@*****.**", "CareerThesaurus", email, "Your Invitation was Accepted", body);
        }
Exemplo n.º 16
0
        public async Task <string> PrepareEmailContent(EmailConfigurationViewModel emailconfigviewmodel)
        {
            var emailconfig = await _repository.Value.Query().Where(_ => _.Language.Language1.ToLower() == emailconfigviewmodel.Language.ToLower() && _.EmailAction.Name.ToLower() == emailconfigviewmodel.ActionName.ToLower()).FirstOrDefaultAsync();

            var filecontent  = File.ReadAllText(HostingEnvironment.MapPath(emailconfig?.FileUrl));
            var emailcontent = EmailTemplateHelper.CustomBindingPropertiesIntoString(filecontent, emailconfigviewmodel, typeof(EmailConfigurationViewModel));

            return(emailcontent);
        }
        private void SendResetPasswordEmail(string email, string password, string name)
        {
            EmailManager        emailManager = new EmailManager();
            EmailTemplateHelper eth          = new EmailTemplateHelper();
            string body = eth.GetTemplate("resetpassword");

            body = body.Replace("{{name}}", name);
            body = body.Replace("{{password}}", password);
            emailManager.SendMail("*****@*****.**", "CareerThesaurus", email, "Account Notification - Reset Password", body);
        }
Exemplo n.º 18
0
 public async Task SendMailToTechspecialist(RequestForDemo requestForDemo)
 {
     var    RecipientEmail     = GetConfiguration("TechspecialistAdminEmail");
     string Subject            = "Request For Demo";
     string Body               = new EmailTemplateHelper().GetTemplateContent("RequestForDemoTemplate_Techspecialist");
     string newTemplateContent = string.Format(Body, requestForDemo.AdministratorEmail);
     //newTemplateContent = newTemplateContent.Replace("[RecipientEmail]", RecipientEmail.Trim());
     Message     message     = new Message(RecipientEmail, Subject, newTemplateContent);
     EmailHelper emailHelper = new EmailHelper();
     await emailHelper.AddEmailToQueue(message);
 }
Exemplo n.º 19
0
 public async Task SendMailToUser(RequestForDemo requestForDemo)
 {
     var    RecipientEmail     = requestForDemo.AdministratorEmail;
     string Subject            = "Techspecialist - ProcureEase App";
     string Body               = new EmailTemplateHelper().GetTemplateContent("RequestForDemoTemplate_User");
     string newTemplateContent = string.Format(Body, requestForDemo.AdministratorFirstName);
     //newTemplateContent = newTemplateContent.Replace("[RecipientEmail]", RecipientEmail.Trim());
     Message     message     = new Message(RecipientEmail, Subject, newTemplateContent);
     EmailHelper emailHelper = new EmailHelper();
     await emailHelper.AddEmailToQueue(message);
 }
Exemplo n.º 20
0
        public void TestGetTemplateContent_WithCorrectTemplateName_WithVariables()
        {
            string originalTemplateContent = new EmailTemplateHelper().GetTemplateContent("SampleTemplate");
            string newTemplateContent      = string.Format(originalTemplateContent, "Muyiwa International", "Annie Connect International");

            Console.WriteLine("Original template content: " + originalTemplateContent);
            Console.WriteLine("New template content: " + newTemplateContent);
            Assert.IsNotNull(originalTemplateContent, "Original template content is null");
            Assert.IsNotNull(originalTemplateContent, "New template content is null");
            Assert.AreNotEqual(originalTemplateContent, newTemplateContent);
        }
Exemplo n.º 21
0
        private static string MapearTemplateHTML(Usuario usuario, string titulo, string templatePath)
        {
            Dictionary <string, string> mapper = new Dictionary <string, string>();

            mapper.Add("{userName}", usuario.UserName);
            mapper.Add("{password}", usuario.Password);


            string template = EmailTemplateHelper.FillTemplate(titulo, templatePath, mapper);

            return(template);
        }
        private void SendInviteEmail(string email, string name, string admin, string guid)
        {
            string              url          = "http://CareerThesaurus.com/SignUp/Counselor/" + guid;
            EmailManager        emailManager = new EmailManager();
            EmailTemplateHelper eth          = new EmailTemplateHelper();
            string              body         = eth.GetTemplate("counselorinvite");

            body = body.Replace("{{name}}", name);
            body = body.Replace("{{admin}}", admin);
            body = body.Replace("{{url}}", url);
            emailManager.SendMail("*****@*****.**", "CareerThesaurus", email, "You are Invited to Join CareerThesaurus", body);
        }
Exemplo n.º 23
0
        private void SendVerificationEmail(string email, string name)
        {
            SimpleAES           aes          = new SimpleAES();
            string              token        = aes.EncryptToString(email.ToLower());
            string              url          = "http://CareerThesaurus.com/Account/ConfirmEmail/" + token;
            EmailManager        emailManager = new EmailManager();
            EmailTemplateHelper eth          = new EmailTemplateHelper();
            string              body         = eth.GetTemplate("confirmemail");

            body = body.Replace("{{name}}", name);
            body = body.Replace("{{url}}", url);
            emailManager.SendMail("*****@*****.**", "CareerThesaurus", email, "Account Notification - Confirm Email", body);
        }
Exemplo n.º 24
0
        private void sendSignupEmail(string name, string email)
        {
            // SimpleAES aes = new SimpleAES();
            EmailManager        emailManager = new EmailManager();
            EmailTemplateHelper eth          = new EmailTemplateHelper();
            //  string token = aes.EncryptToBase64String(email);
            //  string url = "http://www.CareerThesaurus.com/Careers/CareerReport/" + token;
            string body = eth.GetTemplate("signupthankyou");

            body = body.Replace("{{name}}", name);
            // body = body.Replace("{{url}}", url);
            emailManager.SendMail("*****@*****.**", "CareerThesaurus", email, "Thank you for signing up", body);
        }
        private void sendInterestResultEmail(string name, string email)
        {
            SimpleAES           aes          = new SimpleAES();
            EmailManager        emailManager = new EmailManager();
            EmailTemplateHelper eth          = new EmailTemplateHelper();
            string token = aes.EncryptToBase64String(email);
            string url   = "http://www.CareerThesaurus.com/Careers/InterestReport/" + token;
            string body  = eth.GetTemplate("interestresults");

            body = body.Replace("{{name}}", name);
            body = body.Replace("{{url}}", url);
            emailManager.SendMail("*****@*****.**", "CareerThesaurus", email, "Your Career Test Results", body);
        }
Exemplo n.º 26
0
        /// <summary>
        /// Gets the default email template.
        /// </summary>
        /// <param name="emailType">Type of the email.</param>
        /// <returns></returns>
        protected virtual Guid GetDefaultEmailTemplate(string emailType)
        {
            Guid templateId = Guid.Empty;
            var  templates  = EmailTemplateHelper.GetEmailTemplates(String.Format(@"ControlType == ""{0}"" && Condition==""{1}""",
                                                                                  typeof(RegistrationForm).FullName, emailType));

            if (templates != null && templates.Count > 0)
            {
                templateId = templates.First().Key;
            }

            return(templateId);
        }
Exemplo n.º 27
0
        public async Task TestSendMail_SuccessfullyWithAwait_WithTemplate()
        {
            string RecipientEmail = "*****@*****.**";
            string Subject        = "UnitTest: MAIL SENT WITH AWAIT - WITH TEMPLATE";
            string Body           = new EmailTemplateHelper().GetTemplateContent("NMRC-Template");

            EmailHelper.Message message = new EmailHelper.Message(RecipientEmail, Subject, Body);

            EmailHelper emailHelper   = new EmailHelper();
            bool        successStatus = await emailHelper.SendMail(JsonConvert.SerializeObject(message));

            Assert.IsTrue(successStatus);
        }
        public async Task <ActionResult> Register(string id, string firstName, string surname, string nickName, string email, string password, string mobileNo, string birthYear, string postalCode, string address, bool?rememberMe = true)
        {
            var authLogic = LogicContext.Create <AuthLogic>();

            try
            {
                var User = authLogic.AddUpdateUser(Convert.ToInt32(id), firstName, surname, nickName, email, password, mobileNo, birthYear, postalCode, address);
                if (User != null)
                {
                    var loginSession = authLogic.CreateLoginSession(email, password, false);
                    Response.Cookies["AuthCookie"].Value = loginSession.Token;
                    if (rememberMe == true)
                    {
                        Response.Cookies["AuthCookie"].Expires = DateTime.Now.AddYears(1);
                    }

                    EmailTemplateHelper   templates             = new EmailTemplateHelper();
                    EmailTemplateResponse emailTemplateResponse = new EmailTemplateResponse();
                    DIBZ.Common.Model.EmailNotification Email   = new DIBZ.Common.Model.EmailNotification();

                    var emailTemplateLogic = LogicContext.Create <EmailTemplateLogic>();
                    emailTemplateResponse = await emailTemplateLogic.GetEmailTemplate(EmailType.Email, EmailContentType.SignUp);

                    String[] parts    = email.Split(new[] { '@' });
                    String   username = parts[0]; // "hello"
                    String   domain   = parts[1]; // "example.com"

                    templates.AddParam(DIBZ.Common.Model.Contants.AppUserNickName, username);
                    templates.AddParam(DIBZ.Common.Model.Contants.UrlContactUs, string.Format("<a href='{0}'>here</a>", hostName + "/Dashboard/ContactUs"));
                    var emailBody = templates.FillTemplate(emailTemplateResponse.Body);

                    await emailTemplateLogic.SaveEmailNotification(email, emailTemplateResponse.Title, emailBody, EmailType.Email, Priority.Low);

                    EmailHelper.Email(email, emailTemplateResponse.Title, emailBody);
                    //notification to admin if new user registered.
                    EmailHelper.NotificationToAdmin(email, firstName + ' ' + surname, "Signup");
                    await MailChimpsSubs(email, firstName, surname, mobileNo);

                    return(Json(new { IsSuccess = true, AppUserName = loginSession.ApplicationUser.NickName, AppUserId = loginSession.ApplicationUserId }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new { IsSuccess = false, fail = "Some Thing Wrong!" }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                return(Json(new { IsSuccess = false, fail = ex.Message }, JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 29
0
        private void lvEntities_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lvEntities.SelectedItems.Count > 0)
            {
                string entityLogicalName = lvEntities.SelectedItems[0].Tag.ToString();

                Cursor = Cursors.WaitCursor;
                lvEmailTemplates.Items.Clear();

                WorkAsync(new WorkAsyncInfo
                {
                    Message       = "Loading emailTemplates...",
                    AsyncArgument = entityLogicalName,
                    Work          = (bw, evt) =>
                    {
                        evt.Result = EmailTemplateHelper.GetTemplatessByEntity(evt.Argument.ToString(), Service);
                    },
                    PostWorkCallBack = evt =>
                    {
                        if (evt.Error != null)
                        {
                            MessageBox.Show(this, "An error occured: " + evt.Error.Message, "Error",
                                            MessageBoxButtons.OK,
                                            MessageBoxIcon.Error);
                        }
                        else
                        {
                            Cursor        = Cursors.Default;
                            var templates = (EntityCollection)evt.Result;
                            foreach (var entity in templates.Entities)
                            {
                                string isPersonalStr = "False";
                                if (entity.Attributes.Contains("IsPersonal"))
                                {
                                    var ispersonal = (bool)entity.Attributes["IsPersonal"];
                                    isPersonalStr  = (ispersonal) ? "True" : "False";
                                }
                                ListViewItem lvi = new ListViewItem( );
                                lvi.Tag          = entity;
                                lvi.SubItems.Add(entity.GetAttributeValue <string>("title"));
                                lvi.SubItems.Add(isPersonalStr);
                                lvi.SubItems.Add(entity.GetAttributeValue <string>("description"));
                                lvEmailTemplates.Items.Add(lvi);
                            }
                        }
                    }
                });
            }
        }
Exemplo n.º 30
0
        private static string ProcessEmailMessage(long tranId)
        {
            string template = EmailTemplateHelper.GetTemplateFileContents("/Static/Templates/Email/Sales/Delivery.html");

            List <object> dictionary = new List <object>
            {
                AppUsers.GetCurrent().View,
                          Data.Transactions.Delivery.GetSalesDeliveryView(AppUsers.GetCurrentUserDB(), tranId)
            };

            var processor = new EmailTemplateProcessor(template, dictionary);

            template = processor.Process();

            return(template);
        }