API for sending a confirmation email for a new user.

Posted by Community Admin on 04-Aug-2018 19:11

API for sending a confirmation email for a new user.

All Replies

Posted by Community Admin on 16-Aug-2012 00:00

How would I go about sending a confirmation email after a new registration without using the existing registration widget? In other words, what's the namespace/api for sending confirmation emails.

Alternatively, how would I go about adding "sign up to the newsletter" as part of the registration widget? I would idealy like users to be able to decide to sign up for the newsletter as part of the registration process, and not have to fill out extra fields in a separate widget.

Posted by Community Admin on 28-Aug-2012 00:00

I also need to know how to accomplish this in v5.1

Posted by Community Admin on 31-Mar-2013 00:00

Had anyone got an answer in this regard?.

Thank you

Posted by Community Admin on 02-Apr-2013 00:00

If you are using Sitefinity 5.2 or above, then you are probably able to make use of the IEventService and Eventhub. I'm not sure though if you are able to hook in into the user registration process.

Here's a link to the documentation: www.sitefinity.com/.../sitefinity-event-system

Posted by Community Admin on 03-Apr-2013 00:00

Hi guys,

Here are some suggestions:

1. How would I go about sending a confirmation email after a new registration without using the existing registration widget? In other words, what's the namespace/api for sending confirmation emails.

One easy approach would be to replace the default User service with a custom one, that inherits from teh default service. this will allow you to implement the IUsers interface and take advantage of the CreateUser public method. Here's an example of the custom service. Simply add a class file to you project wtih the following code in it: 

public class UsersServiceCustom:Users, IUsers
    public WcfMembershipUser CreateUser(WcfMembershipUser user, string userId, string provider)
    
        //you can get  ahold of the created user from the User parameter of the method
        //e.g.
        var myUser = user;
        return base.CreateUser(user, userId, provider);
    
Then in the Users.svc file, located under /Services, change the declaration to point to your custom service (UsersServiceCustom is the name of my custom service class):
<%@ ServiceHost
    Language="C#"
    Debug="false"
    Service="SitefinityWebApp.UsersServiceCustom"
    Factory="Telerik.Sitefinity.Web.Services.WcfHostFactory"
 %>

Now, having this allows you to execute your own logic whena  user is created and you have access to the user parameter (for example yuo can get the user email from it). Here's a sample code for sending emails with Sitefinity:
var smtpSettings = Config.Get<SystemConfig>().SmtpSettings;
MailMessage message = new MailMessage();
message.From = new MailAddress(smtpSettings.DefaultSenderEmailAddress);
message.To.Add(new MailAddress("someone@example.com"));
StringBuilder sb = new StringBuilder();
sb.AppendFormat("You have been registered");
message.Subject = "Comments notification";
message.Body = sb.ToString();
message.IsBodyHtml = true;
message.BodyEncoding = Encoding.Unicode;
message.SubjectEncoding = Encoding.Unicode;
EmailSender.Get().Send(message);

2) Alternatively, how would I go about adding "sign up to the newsletter" as part of the registration widget?

 You will find attached a modified Registration form control with a custom template, where I've added a checkBox, and depending on whether this checkBox  is checked, I'm adding the user to a mailing list. All the best,
Jen Peleva
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

This thread is closed