예제 #1
0
        private async void sendWelcomeEmail(String userId, String email, UrlHelper urlHelper, string recipientName, System.Web.Http.Routing.UrlHelper apiUrlHelper)
        {
            string CallbackURL = "";
            string code        = userManager.GenerateEmailConfirmationToken(userId);

            // webapi will send null urlhelper and defined base URL in CallbackURL
            if (urlHelper != null)
            {
                string protocol    = urlHelper.RequestContext.HttpContext.Request.Url.Scheme;
                var    callbackUrl = urlHelper.Action("ConfirmEmail", "Account", new { userId = userId, code = code }, protocol: protocol);
                CallbackURL = callbackUrl;
            }
            else
            {
                var callbackUrl = apiUrlHelper.Route("Default", new { userId = userId, code = code });
                CallbackURL = apiUrlHelper.Request.RequestUri.Scheme + "://" + apiUrlHelper.Request.RequestUri.Authority + "/" + callbackUrl;
            }


            EmailManager emailManager = new EmailManager();

            emailManager.NewEmail();
            emailManager.RecipientEmailAddress = email;
            emailManager.RecipientName         = recipientName;
            emailManager.EmailSubject          = " Welcome to VAULTLife.com! ";
            //emailManager.EmailBodyText = "<!DOCTYPE html><html xmlns='http://www.w3.org/1999/xhtml'><head><title></title><link rel='stylesheet' href='http://www.vaultlife.com/Content/images/email/email-styles.css' /></head><body><link rel='stylesheet' href='http://www.vaultlife.com/Content/images/email/email-styles.css' /><div class='header' style='background-color: black;'><img src='https://www.vaultlife.com/Content/images/logo.png' /></div><div class='content'><h1> WELCOME</h1><p>Welcome to VAULTLife.com, a world in which anything is possible! Its time to stop worrying about probabilities and wondering about possibilities! Begin a journey today with VAULTLife.com where you replace your to-do list with your bucket list! </p><p>We all have different dreams. Our worlds are coloured with different fantasies and we want to help you achieve yours! Based on this, we would like to tailor make your VAULTLife.com experience, so please select the link below to confirm that your details are correct and that we have all we need to make your VAULTLife.com experience once in a lifetime! </p><p>Please confirm your account by clicking <a href=\"" + CallbackURL + "\">here</a></p></div><div class='footer'><table class='signature' cellspacing='0'><tr><td class='details'><img src='http://www.vaultlife.com/Content/images/email/vl-team-sig_01.jpg' alt='Vaultlife.com' /><div class='content'><h2>VAULTLife TEAM</h2><div><strong>Email:</strong> &nbsp; <a href='mailto:[email protected]'>[email protected]</a></div><div><strong>Tel:</strong> &nbsp; <span>+27 86 123 6334</span></div><div><strong>Fax:</strong> &nbsp; <span>+27 86 123 6334</span></div><div><span class='small'>The Embassy, 50 Mulbarton Rd, Beverly, Johannesburg, 1296</span></div><div><a href='http://www.vaultlife.com'><strong>www.vaultlife.com</strong></a></div></div></td><td class='promo'><img src='http://www.vaultlife.com/Content/images/email/vl-team-sig_02.jpg' alt='Vaultlife.com' /></td></tr></table></div></body></html>";
            emailManager.EmailBodyText = "<!DOCTYPE html><html xmlns='http://www.w3.org/1999/xhtml'><head><title></title></head><body style='margin: 0px; padding: 0px;'><div class='header' style='background-color: black; padding: 15px 20px;'><img src='http://www.vaultlife.com/Content/images/logo.png' alt='Vaultlife.com' style='width: 127px; height: 39px;' /></div><div class='content' style='padding: 15px 30px; font-family: Segoe UI, Calibri, Arial, Helvetica, sans-serif; max-width: 800px; width: 100%;'><h1>WELCOME</h1><p>Welcome to VAULTLife.com, a world in which anything is possible! Its time to stop worrying about probabilities and wondering about possibilities! Begin a journey today with VAULTLife.com where you replace your to-do list with your bucket list!</p><p>We all have different dreams. Our worlds are coloured with different fantasies and we want to help you achieve yours! Based on this, we would like to tailor make your VAULTLife.com experience, so please select the link below to confirm that your details are correct and that we have all we need to make your VAULTLife.com experience once in a lifetime!</p><p>Please confirm your account by clicking <a href=\"" + CallbackURL + "\">here</a></p><p>code: " + code + "</p></div><div class='footer' style='padding: 15px 30px; font-family: 'Segoe UI', Calibri, Arial, Helvetica, sans-serif;'><table class='signature' cellspacing='0' cellpadding='0'><tr><td class='details' style='width: 308px; vertical-align: top; background-color: #161616;' valign='top'><img src='http://www.vaultlife.com/Content/images/email/vl-team-sig_01.jpg' alt='Vaultlife.com' style='width: 308px; height: 79px;' /><div class='content' style='padding: 0px 15px; font-size: 11px; color: white;'><h2 style='margin: 0px;font-size: 20px;'>VAULTLife TEAM</h2><div><strong>Email:</strong> &nbsp; <a href='mailto:[email protected]' style='color: #eeeeee;'>[email protected]</a></div><div><strong>Tel:</strong> &nbsp; <span>+27 86 123 6334</span></div><div><strong>Fax:</strong> &nbsp; <span>+27 86 123 6334</span></div><div><span class='small'>The Embassy, 50 Mulbarton Rd, Beverly, Johannesburg, 1296</span></div><div><a href='http://www.vaultlife.com' style='color: #eeeeee;'><strong>www.vaultlife.com</strong></a></div></div></td><td class='promo' valign='top' style='vertical-align: top; background-color: #161616; width: 220px'><img src='http://www.vaultlife.com/Content/images/email/vl-team-sig_02.jpg' alt='Vaultlife.com' style='width: 228px; height: 220px;' /></td></tr></table></div></body></html>";
            emailManager.QueueEmail();
        }
예제 #2
0
        public static bool SetHeaderLocation(this HttpResponseMessage response, HttpRequestMessage request, ActionResult result, NameValueCollection queryStringParams = null)
        {
            var url = new System.Web.Http.Routing.UrlHelper(request);

            var routeVals     = result.GetRouteValueDictionary();
            var responseRoute = url.Route(null, routeVals);

            if (!string.IsNullOrWhiteSpace(responseRoute))
            {
                var routeUri = new Uri(request.RequestUri, responseRoute);
                var query    = HttpUtility.ParseQueryString(routeUri.Query);
                if (queryStringParams != null)
                {
                    query.Add(queryStringParams);
                    responseRoute = string.Format("{0}{1}",
                                                  routeUri.AbsolutePath,
                                                  query.HasKeys()
                                                      ? string.Format("?{0}", query)
                                                      : string.Empty);
                }

                response.Headers.Location = new Uri(request.RequestUri, responseRoute);
                return(true);
            }

            return(false);
        }