Last one week, I was working in a little project were I used membership controls extensively. Main advantage of membership controls is productivity i.e. it reduces the development time a lot.
In addition to productivity advantage, these membership controls are fully customizable. This is also a main reason for these controls to be used in various applications.
In the project, I have customized the membership controls at many places. Therefore, I am planning to write a set of blogs to explain what are the customization options in membership controls I have used.
In this blog, I am going to talk about customization of e-mail content, which is sent from membership controls. The membership controls that sent email to the user are passwordrecovery control and createuserwizard control. I will talk about when e-mail is sent in createuserwizard control and how to enable this feature in my next blog.
Passwordrecovery control will send an email with new password when user request for password reset. By default, Passwordrecovery control sent an email with default content, which might not include your company name or your company website link.
Mostly you might want to customize the email sent to the customer. Passwordrecovery control provide an option for this through MailDefinition property, it has following properties
- BodyFileName – this property can be used to specify the text file path which contains the conent of the e-mail body.
- Subject – to specify the subject for the email
- From – this property is used to specify from address.
- CC – to specify Carbon Copy email.
- IsBodyHTML – to specify whether body is sent as html.
- Priority – to set the priority of the mail.
Using these properties, you can customize email content. However, the next question, which comes to our mind, is how to add information about user in the mail. For example, you might want to add username and password detail in the mail. By default membership control provides following placeholders,
1. <% UserName %> - this placeholder will be replaced with username when the mail is sent to the user
2. <% Password %> - this placeholder will be replaced with password when themail is sent to the user.
These placeholders can be used in the text file, which you are specifying in the BodyFileName property of the MailDefinition property.
Since only two placeholders are supported by membership controls, you might further want to customize this. For example, you might want to send email or security question or your application specific user data along with username in the mail. In that case, you can use SendMail event of the membership control to customize further, for example to send email information in the mail. You can have <%Mail%> placeholder in your BodyFileName file, and in sendingmail event, you can replace this placeholder with the email of the user.
void PasswordRecovery1_SendingMail(object sender, MailMessageEventArgs e)
{
MembershipUser user = Membership.GetUser(User.Identity.Name);
e.Message.Body = e.Message.Body.Replace("<%Mail%>", user.Email);
}
Note : Using membership API, you can get the email Id of the user.
If you are in US and if you are looking for a change, TechSmarts is looking for smart people to join them. Current opening are in following areas,
- SAP - All modules
- Microsoft .NET Developers
- Java Developers
- Oracle Developers
- Oracle DBAs
- UNIX System Administrators
- Network Engineers
- Technical Leads
- Project Managers
- Business Analysts
- QA Leads
If your friend is looking for a change, you can refer your friend for this job. If your friend works for more than 6 months, you can get a good referral fee. Not bad for helping out a colleague or friend.
Microsoft has released a set of online resources for VSTS. They have online training resources for various levels from New to Intermediate to Expert level, its a one stop resource for your VSTS learning’s
Check out "Expand your opportunities" for more details...
Check out this cool add-in "Cool Commands". It does very simple tasks, but all those are all very useful tasks. Here are few tasks which I liked it,
- Collapse All Projects - I don’t know how Microsoft didn’t provide this option in solution explorer. Anyway this add-in provides, so not a problem
- Resolve Project References - It will automatically resolve the project reference and include those projects in your solution. Check out the link for more details
- Copy/Paste References - You can copy and past reference between projects like copy/paste text.
- Demo Font - Ultimate (very useful during session)
- Wheel Font Sizing - It didn’t work for me... I need to figure it out...
- Visual Studio Prompt from here
- Open project folder
- Build current Project from code file only.
It's free, so dont wait for anything else. Just download and use it. It will surely helps everyone who lives with VS2005.