Hi Anh,
You need to trigger this email manually from the code. For a correct example you can refer to \CMS\CMSWebParts\Membership\Registration\RegistrationForm.ascx.cs webpart code. There you can find the following section:
#region "Welcome Emails (confirmation, waiting for approval)"
bool error = false;
EmailTemplateInfo template = null;
string emailSubject = null;
// Send welcome message with username and password, with confirmation link, user must confirm registration
if (requiresConfirmation)
{
template = EmailTemplateProvider.GetEmailTemplate("RegistrationConfirmation", siteName);
emailSubject = EmailHelper.GetSubject(template, GetString("RegistrationForm.RegistrationConfirmationEmailSubject"));
}
// Send welcome message with username and password, with information that user must be approved by administrator
else if (SendWelcomeEmail)
{
if (requiresAdminApprove)
{
template = EmailTemplateProvider.GetEmailTemplate("Membership.RegistrationWaitingForApproval", siteName);
emailSubject = EmailHelper.GetSubject(template, GetString("RegistrationForm.RegistrationWaitingForApprovalSubject"));
}
// Send welcome message with username and password, user can logon directly
else
{
template = EmailTemplateProvider.GetEmailTemplate("Membership.Registration", siteName);
emailSubject = EmailHelper.GetSubject(template, GetString("RegistrationForm.RegistrationSubject"));
}
}
if (template != null)
{
// Create relation between contact and user. This ensures that contact will be correctly recognized when user approves registration (if approval is required)
// New contact with user data is created in case it is not disabled by Data protection settings, otherwise an anonymous contact is created. Moreover an another
// anonymous contact could be created during approval process when a new browser is used for approval step (when contact isn't in browser cookies).
int contactId = ModuleCommands.OnlineMarketingGetCurrentContactID();
if (contactId > 0)
{
Service.Resolve<IContactRelationAssigner>().Assign(ui.UserID, MembershipType.CMS_USER, contactId, new UserContactDataPropagationChecker());
}
// Email message
EmailMessage email = new EmailMessage();
email.EmailFormat = EmailFormatEnum.Default;
email.Recipients = ui.Email;
email.From = SettingsKeyInfoProvider.GetValue(siteName + ".CMSNoreplyEmailAddress");
email.Subject = emailSubject;
try
{
var resolver = MembershipResolvers.GetMembershipRegistrationResolver(ui, AuthenticationHelper.GetRegistrationApprovalUrl(ApprovalPage, ui.UserGUID, siteName, NotifyAdministrator));
EmailSender.SendEmailWithTemplateText(siteName, email, template, resolver, true);
}
catch (Exception ex)
{
EventLogProvider.LogException("E", "RegistrationForm - SendEmail", ex);
error = true;
}
}
// If there was some error, user must be deleted
if (error)
{
ShowError(GetString("RegistrationForm.UserWasNotCreated"));
// Email was not send, user can't be approved - delete it
UserInfoProvider.DeleteUser(ui);
return;
}
#endregion