Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. I had an error of Email in line " dynamic email = new Email("ChngPasswordEmail");" which say's The type or Namespace name "Email" could not be found Pin

I had an error of Email in line " dynamic email = new Email("ChngPasswordEmail");" which say's The type or Namespace name "Email" could not be found Pin

Scheduled Pinned Locked Moved C#
asp-netdatabasebusinessarchitecturehelp
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 13642228
    wrote on last edited by
    #1

    public void ResetPassword(UserModel model, string Name)
    {

            using (var db = new sortit\_internEntities())
            {
                
                string emailAddress = (from info in db.users
                                       where info.name.Equals(model.Name)
                                       select info.email).Single();
    
                if (!string.IsNullOrEmpty(emailAddress))
                {
                    string confirmationToken =
                        WebSecurity.GeneratePasswordResetToken(model.Name);
                    dynamic email = new Email("ChngPasswordEmail");
                    email.To = emailAddress;
                    email.UserName = model.Name;
                    email.ConfirmationToken = confirmationToken;
                    email.Send();
                    
                }
               
                
            }
        }
    

    for resetting password for login and yes I am new to MVC, this code is in business layer of MVC for kind Information

    CHill60C OriginalGriffO D 3 Replies Last reply
    0
    • U User 13642228

      public void ResetPassword(UserModel model, string Name)
      {

              using (var db = new sortit\_internEntities())
              {
                  
                  string emailAddress = (from info in db.users
                                         where info.name.Equals(model.Name)
                                         select info.email).Single();
      
                  if (!string.IsNullOrEmpty(emailAddress))
                  {
                      string confirmationToken =
                          WebSecurity.GeneratePasswordResetToken(model.Name);
                      dynamic email = new Email("ChngPasswordEmail");
                      email.To = emailAddress;
                      email.UserName = model.Name;
                      email.ConfirmationToken = confirmationToken;
                      email.Send();
                      
                  }
                 
                  
              }
          }
      

      for resetting password for login and yes I am new to MVC, this code is in business layer of MVC for kind Information

      CHill60C Offline
      CHill60C Offline
      CHill60
      wrote on last edited by
      #2

      Put the appropriate Using statement at the top of the class module and make sure you have included a reference to the appropriate assembly

      U 1 Reply Last reply
      0
      • U User 13642228

        public void ResetPassword(UserModel model, string Name)
        {

                using (var db = new sortit\_internEntities())
                {
                    
                    string emailAddress = (from info in db.users
                                           where info.name.Equals(model.Name)
                                           select info.email).Single();
        
                    if (!string.IsNullOrEmpty(emailAddress))
                    {
                        string confirmationToken =
                            WebSecurity.GeneratePasswordResetToken(model.Name);
                        dynamic email = new Email("ChngPasswordEmail");
                        email.To = emailAddress;
                        email.UserName = model.Name;
                        email.ConfirmationToken = confirmationToken;
                        email.Send();
                        
                    }
                   
                    
                }
            }
        

        for resetting password for login and yes I am new to MVC, this code is in business layer of MVC for kind Information

        OriginalGriffO Offline
        OriginalGriffO Offline
        OriginalGriff
        wrote on last edited by
        #3

        Look at the error message:

        The type or Namespace name "Email" could not be found

        It's pretty explicit! The compiler does not know what the Email class is: it hasn't got one for you to use. Either you haven't added a reference to the assembly containing the class to your project, and a using statement at the top of the file to the namespace the class is in; or just the using statement is missing; or you do not have a class called Email at all. Hover the mouse over the word "Email" and a little blue bar will appear at the beginning. Hover the mouse over that and a drop down will open suggesting ways to fix it.

        Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!

        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
        "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

        1 Reply Last reply
        0
        • CHill60C CHill60

          Put the appropriate Using statement at the top of the class module and make sure you have included a reference to the appropriate assembly

          U Offline
          U Offline
          User 13642228
          wrote on last edited by
          #4

          Ya I had add all references for it!

          1 Reply Last reply
          0
          • U User 13642228

            public void ResetPassword(UserModel model, string Name)
            {

                    using (var db = new sortit\_internEntities())
                    {
                        
                        string emailAddress = (from info in db.users
                                               where info.name.Equals(model.Name)
                                               select info.email).Single();
            
                        if (!string.IsNullOrEmpty(emailAddress))
                        {
                            string confirmationToken =
                                WebSecurity.GeneratePasswordResetToken(model.Name);
                            dynamic email = new Email("ChngPasswordEmail");
                            email.To = emailAddress;
                            email.UserName = model.Name;
                            email.ConfirmationToken = confirmationToken;
                            email.Send();
                            
                        }
                       
                        
                    }
                }
            

            for resetting password for login and yes I am new to MVC, this code is in business layer of MVC for kind Information

            D Offline
            D Offline
            Dave Kreskowiak
            wrote on last edited by
            #5

            Nobody else caught this, but why are you using "dynamic"? It's not for the use case what you're using it. That line should read:

            Email email = new Email("ChngPasswordEmail");
            

            Dynamic treats your object as an Object type, removes all static checks at compile time, and slows down the code a bit due to having to resolve method calls at runtime. It also makes it harder to write the code and debug it. It should be rare that you have to use the dynamic type.

            Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
            Dave Kreskowiak

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups