示例#1
0
        private async Task <string> SendEmailConfirmationTokenAsync(string userID, string subject)
        {
            string code = await UserManager.GenerateEmailConfirmationTokenAsync(userID);

            var user = await UserManager.FindByIdAsync(userID);

            System.Web.Mvc.UrlHelper Url = new System.Web.Mvc.UrlHelper(HttpContext.Current.Request.RequestContext, RouteTable.Routes);
            var callbackUrl = Url.Action("ConfirmEmail", "Account",
                                         new { userId = userID, code = code }, protocol: HttpContext.Current.Request.Url.Scheme);
            var message = await PensionSetup.EmailTemplate("_Email");

            var Username = PensionSetup.GetMemberNamesAsync(user.Email, user);

            message = message.Replace("@ViewBag.Name", CultureInfo.CurrentCulture.TextInfo.ToTitleCase(Username));
            //message = message.Replace("@ViewBag.Link", "intent:#Intent;action=ke.co.synobrain.alexanderforbes;category=android.intent.category.DEFAULT;category=android.intent.category.BROWSABLE;S.msg_from_browser=Launched%20from%20Browser;end");
            message = message.Replace("@ViewBag.Link", callbackUrl);
            message = message.Replace("@ViewBag.Subject", subject);
            await UserManager.SendEmailAsync(userID, subject, message);

            return(callbackUrl);
        }