//called after Membership User has been created, now add any additional profile info needed protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e) { try { int unitID = 0; if (!String.IsNullOrEmpty(Request.QueryString["uid"])) { unitID = int.Parse(Request.QueryString["uid"]); } MembershipUser user = Membership.GetUser(this.CreateUserWizard1.UserName); bool success = WRObjectModel.Users.User.RegisterHomeOwnerUser(user, unitID); //create new profile on the new user and save extra info if (success) { System.Web.Profile.ProfileBase profile = System.Web.Profile.ProfileBase.Create(CreateUserWizard1.UserName, true); profile.SetPropertyValue("FirstName", ((TextBox) this.CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl ( "FirstName")).Text); profile.SetPropertyValue("LastName", ((TextBox) this.CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl ( "LastName")).Text); profile.SetPropertyValue("PhoneNumber", ((TextBox) this.CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl ( "Phone")).Text); //Save profile since we created it manually profile.Save(); WRObjectModel.Users.Membership.UpdateUserWarrantyReminder(user.UserName, true, true); TextReader htmlReader = new StreamReader( this.OpenFile(Path.Combine(Settings.Default.EmailTemplatePath, @"MessageTemplates\BuilderPortalPreRegister_HTML.txt"))); TextReader txtReader = new StreamReader( this.OpenFile(Path.Combine(Settings.Default.EmailTemplatePath, @"MessageTemplates\BuilderPortalPreRegister_PlainText .txt"))); string htmlEmailBody; string txtEmailBody; try { htmlEmailBody = htmlReader.ReadToEnd(); txtEmailBody = txtReader.ReadToEnd(); } finally { htmlReader.Close(); txtReader.Close(); } EmailTemplate emailTemplate = new EmailTemplate(); //Get the UserId of the just-added user Guid newUserId = (Guid)user.ProviderUserKey; //get the full URL string urlBase = Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath; string verifyUrl = BuilderRegistration_Verification.GetUrl(newUserId, user.UserName); string fullUrl = urlBase + verifyUrl; const string subject = "Your Online Homeowner Portal"; const string from = "*****@*****.**"; //Replace <%VerificationUrl%> with the appropriate URL and querystring htmlEmailBody = htmlEmailBody.Replace("<%VerificationUrl%>", fullUrl); txtEmailBody = txtEmailBody.Replace("<%VerificationUrl%>", fullUrl); //Enter home info into email if (unitID > 0) { WRObjectModel.Unit u = WRObjectModel.Unit.Get(unitID); HomeInformationPackage hip = HomeInformationPackage.Get(unitID); htmlEmailBody = htmlEmailBody.Replace("<%HomeID%>", u.Purchaser.UserName); htmlEmailBody = htmlEmailBody.Replace("<%Address%>", u.GetSingleLineAddress()); htmlEmailBody = emailTemplate.GetMatchPortalHtmlMessageTemplate(htmlEmailBody, hip, subject, user.UserName, user.Email); txtEmailBody = txtEmailBody.Replace("<%HomeID%>", u.Purchaser.UserName); txtEmailBody = txtEmailBody.Replace("<%Address%>", u.GetSingleLineAddress()); txtEmailBody = emailTemplate.GetMatchPortalTxtMessageTemplate(txtEmailBody, user.UserName, user.Email); } else { htmlEmailBody = htmlEmailBody.Replace("<%HomeID%>", "(not available)"); htmlEmailBody = htmlEmailBody.Replace("<%Address%>", "(not available)"); txtEmailBody = txtEmailBody.Replace("<%HomeID%>", "(not available)"); txtEmailBody = txtEmailBody.Replace("<%Address%>", "(not available)"); } MailHelper.SendMailMessage(from, user.Email, "", "", subject, txtEmailBody, htmlEmailBody, MailPriority.Normal); } } catch { Literal msg = (Literal)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("ErrorMessage"); msg.Text = "Error creating user. Likely cause is an invalid email."; } }