1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Emailing to registered users

Emailing to registered users

3 posts, 0 answered
  1. anand
    anand avatar
    59 posts
    Registered:
    11 Jun 2008
    07 Jan 2009
    Link to this post

    I have one requirement that admin should receive an email for every new user sign up and user should receive and email once admin will change his permission. How can we implement this?
    Does Sitefinity support custom emailing to registered customer from admin section?

  2. anand
    anand avatar
    59 posts
    Registered:
    11 Jun 2008
    07 Jan 2009
    Link to this post
    Above text is not readable, I am posting it again.
    I have one requirement that admin should receive an email for every new user sign up and user should receive and email once admin will change his permission. How can we implement this?
    Does Sitefinity support custom emailing to registered customer from admin section?
    I have also seen Email.aspx in admin section in CMSadmin directory, what is use of that file?
  3. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    08 Jan 2009
    Link to this post
    Hello anand,

    It is possible to implement sending of emails, for instance when a new user has been registered. It depends on where you want to do this and which interface you are going to use. Here are two examples that shows sending of emails when a user has been registered. The first one is related to the Sitefinity Admin Interface - when you manage users through Sitefinity Administration. The second one uses CreateUserWizardControl.

    We are going to edit the following file and add handlers for CreatedUser.

    ~\Sitefinity\Admin\CmsAdmin\Users.aspx.cs

     protected override void OnInit(EventArgs e) 
        { 
            base.OnInit(e); 
            manageUsers.ModeChanged += new EventHandler(manageUsers_ModeChanged); 
            manageUsers.CreatedRole += new RoleCreatedEventHandler(manageUsers_CreatedRole); 
     
            // add new handler 
            manageUsers.CreatedUser += new EventHandler(manageUsers_CreatedUser); 
     
        } 
     
        void manageUsers_CreatedUser(object sender, EventArgs e) 
        { 
            // add logic here 
            MembershipUser user = manageUsers.Manager.GetUser(manageUsers.UserName); 
            MailMessage message = new MailMessage(); 
            message.To.Add(user.Email); 
        } 

    The second way using CreateUserWizardControl, ~\Sitefinity\UserControls\Login\CreateUserWizardControl.ascx.cs

    protected override void OnInit(EventArgs e) 
        { 
            base.OnInit(e); 
     
            this.CreateUserWizard1.CreatedUser += new EventHandler(CreateUserWizard1_CreatedUser); 
        } 
     
     
        void CreateUserWizard1_CreatedUser(object sender, EventArgs e) 
        { 
            UserManager manager = new UserManager(CreateUserWizard1.MembershipProvider); 
            if (defaultRoles != null
            { 
                foreach (string role in defaultRoles) 
                    manager.AddUserToRole(CreateUserWizard1.UserName, role); 
            } 
            this.ManageProfile.SetProfileProperties(CreateUserWizard1.UserName); 
     
            MailMessage message = new MailMessage(); 
            message.To = ""
     
            //optionally try catch block 
            try 
            { 
                SmtpMail.SmtpServer = "smtp server name or IP address"
                SmtpMail.Send(message); 
            } 
            catch (HttpException ex) 
            { 
                Response.Write("HTTP Error occured: " + ex.ToString()); 
            } 
            catch (Exception ex) 
            { 
                Response.Write("Error occured: " + ex.ToString()); 
            } 
           
     
        } 

    I hope this helps.

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Register for webinar
3 posts, 0 answered