Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8502203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:25:08+00:00 2026-06-11T01:25:08+00:00

Trying to create an email verification in C# based on this article . I’ve

  • 0

Trying to create an email verification in C# based on this article.

I’ve created a jangosmtp account to send the email. However it doesn’t seem to be working.

Web.config:

  <system.net>
    <mailSettings>
      <smtp>
        <network
             host="relay.example.com" port="25" userName="********" password="********" />
      </smtp>
    </mailSettings>
  </system.net>

Registration.aspx

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <asp:CreateUserWizard ID="CreateUserWizard1" runat="server" DisableCreatedUser="True">
        <WizardSteps>
            <asp:CreateUserWizardStep ID="CreateUserWizardStep1" runat="server" />
            <asp:CompleteWizardStep ID="CompleteWizardStep1" runat="server" />
        </WizardSteps>
        <MailDefinition BodyFileName="NewAccountTemplate.htm" From="example@example.com" IsBodyHtml="True"  Subject="Steps to activate your new account..." Priority="High" />
    </asp:CreateUserWizard>
</asp:Content>

Registration.aspx.cs:

namespace WebSite
{
    public partial class Registration : System.Web.UI.Page
    {
        protected void CreateUserWizard1_SendingMail(object sender, MailMessageEventArgs e)
        {
            //Send an email to the address on file
            MembershipUser userInfo = Membership.GetUser(CreateUserWizard1.UserName);

            //Construct the verification URL
            string verifyUrl = Request.Url.GetLeftPart(UriPartial.Authority) + Page.ResolveUrl("~/Verify.aspx?ID=" + userInfo.ProviderUserKey.ToString());

            //Replace <%VerifyUrl%> placeholder with verifyUrl value
            e.Message.Body = e.Message.Body.Replace("<%VerifyUrl%>", verifyUrl);
        }
    }
}

NewAccountTemplate.htm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Steps to activate your account...</title>
</head>
<body style="font-family:Verdana;">

    <h2>
        Welcome to My Website!</h2>
    <p>
        Hello, <%UserName%>. You are receiving this email because you recently created a new account at my 
        site. Before you can login, however, you need to first visit the following link:</p>
    <p>
        <a href="<%VerifyUrl%>"><%VerifyUrl%></a></p>
    <p>
        After visiting the above link you can log into the site!</p>
    <p>
        If you have any problems verifying your account, please reply to this email to 
        get assistance.</p>
    <p>
        Thanks!</p>

</body>
</html>

Verify.aspx.cs:

namespace WebSite
{
    public partial class Verify : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //Make sure that a valid query string value was passed through
            if (string.IsNullOrEmpty(Request.QueryString["ID"]) || !Regex.IsMatch(Request.QueryString["ID"], "[0-9a-f]{8}\\-([0-9a-f]{4}\\-){3}[0-9a-f]{12}"))
            {
                InformationLabel.Text = "An invalid ID value was passed in through the querystring.";
            } else {
                //ID exists and is kosher, see if this user is already approved
                //Get the ID sent in the querystring
                Guid userId = new Guid(Request.QueryString["ID"]);

                //Get information about the user
                MembershipUser userInfo = Membership.GetUser(userId);
                if (userInfo == null) {
                    //Could not find user!
                    InformationLabel.Text = "The user account could not be found in the membership database.";
                } else {
                    //User is valid, approve them
                    userInfo.IsApproved = true;
                    Membership.UpdateUser(userInfo);

                    //Display a message
                    InformationLabel.Text = "Your account has been verified and you can now log into the site.";
                }
            }
        }
    }
}

Two things concerning me which is what im assuming is not causing it to work.

  1. How does it know to even send NewAccountTemplate.htm message? UPDATE ahh i see where that happens in the createuserwizard1 now. Still getting this error message.
  2. On NewAccountTemplate.htm i get a warning message:

Warning ‘<% VerifyUrl %>’ was not found.

What’s going wrong? Am i overlooking something.

UPDATE 2:

If i add onsendingmail=”CreateUserWizard1_SendingMail” It generate a link, however the link does not work because the user never gets added into the database i checked this. So when i click the link on the email it says bad request obv due to the fact there is no user with this ID. If i remove that line of code the user gets created but no link gets generated :/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T01:25:10+00:00Added an answer on June 11, 2026 at 1:25 am

    I finally got this to work.

    1. onsendingmail=”CreateUserWizard1_SendingMail” This should be in create user wizard.

      <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server" onsendingmail="CreateUserWizard1_SendingMail">
      <asp:CreateUserWizard ID="CreateUserWizard1" runat="server" DisableCreatedUser="True">
          <WizardSteps>
              <asp:CreateUserWizardStep ID="CreateUserWizardStep1" runat="server" />
              <asp:CompleteWizardStep ID="CompleteWizardStep1" runat="server" />
          </WizardSteps>
          <MailDefinition BodyFileName="NewAccountTemplate.htm" From="example@example.com" IsBodyHtml="True"  Subject="Steps to activate your new account..." Priority="High" />
      </asp:CreateUserWizard>
      

    2. use just <%VerificationUrl%> in NewAccountTemplate.htm

    3. Change registration.aspx.cs to

      // Get the UserId of the just-added user
      MembershipUser newUser = Membership.GetUser(CreateUserWizard1.UserName);
      Guid newUserId = (Guid)newUser.ProviderUserKey;
      
      // Determine the full verification URL (i.e., http://yoursite.com/Verification.aspx?ID=...)
      string urlBase = Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath;
      string verifyUrl = "Verify.aspx?ID=" + newUserId.ToString();
      string fullUrl = urlBase + verifyUrl;
      
      // Replace <%VerificationUrl%> with the appropriate URL and querystring
      e.Message.Body = e.Message.Body.Replace("<%VerificationUrl%>", fullUrl);
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently trying to create an email application using Rails and Sendgrid. This application
Am trying to create a link to create an email to send information to
I am trying to create a very simple (text based for now) email app
I'm trying to create a nightly email based off of some of the stats
I'm trying to create a user control template that I can send as email.
I am trying to create an email form that allows you to send an
I'm trying to send this string to my Stripe account to process a transaction,
I am trying to use python's imaplib to create an email and send it
I'm trying to create a work flow that will send an email to the
I am trying to create & save images from data in an email from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.