Home > ASP.Net > Create User Wizard Sending Email

Create User Wizard Sending Email


Hi

try this example:

protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
    {
        //Send email to user for verifying account
        CreateUserWizard cuw = (CreateUserWizard)sender;
        MembershipUser user = Membership.GetUser(cuw.UserName);
        Guid userId = (Guid)user.ProviderUserKey;
        System.Net.Mail.MailMessage EmailMsg = new System.Net.Mail.MailMessage("info@ask.com", CreateUserWizard1.Email);
        EmailMsg.Subject = "Email Verification from ask.com";
        EmailMsg.IsBodyHtml = true;
        EmailMsg.Body = "Thanks for registering with www.ask.com!<br /><br />Your activation link : http://www.ask.com/activate.aspx?ID=" + userId.ToString() + ">Link.";
        System.Net.Mail.SmtpClient mailClient = new System.Net.Mail.SmtpClient();
        //This object stores the authentication values
        System.Net.NetworkCredential basicAuthenticationInfo = new System.Net.NetworkCredential("smtpserverinfo", "smtpserverpassword");

        mailClient.Host = "mail.ask.com";
        mailClient.UseDefaultCredentials = false;
        mailClient.Credentials = basicAuthenticationInfo;
        mailClient.Send(EmailMsg);

    }

and in activate.aspx:

    

 protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            // If querystring value is missing, send the user to ManageUsers.aspx
            string userName = Request.QueryString["ID"];
            if (string.IsNullOrEmpty(userName))
                Response.Redirect("AccessDenied.aspx");
            // Get information about this user
            MembershipUser usr = Membership.GetUser(userName);
            if (usr == null)
                Response.Redirect("AccessDenied.aspx");

        }

        if (Request.QueryString["ID"] != null)
        {
            //-- Decrypt Querystring from Register page
            string Querystring = Request.QueryString["ID"].ToString();
            Guid oGuid = new Guid(QueryString);
            MembershipUser oUser = Membership.GetUser(oGuid);

            lblName.Text = oUser.UserName;

            if (oUser != null && oUser.IsApproved == false)
            {
                oUser.IsApproved = true;
                Membership.UpdateUser(oUser);
                //System.Web.Security.FormsAuthentication.RedirectFromLoginPage(oUser.UserName, false);
            }
        }
        else
        {
            Response.Redirect("AccessDenied.aspx");
        }
    }

for more information check this link

http://forums.asp.net/p/1205725/2110325.aspx

http://forums.asp.net/t/1289043.aspx

Good Luck

Advertisements
Categories: ASP.Net
  1. Johnf601
    May 6, 2014 at 9:34 am

    This is really interesting, You’re a very skilled blogger. I have joined your feed and look forward to seeking more of your magnificent post. Also, I have shared your web site in my social networks! gddcfcfdgdge

  2. Johna732
    May 6, 2014 at 9:34 am

    Wonderful site. Plenty of useful info here. I’m sending it to a few pals ans additionally sharing in delicious. And naturally, thank you to your sweat! ddgekdfdcgec

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: