Almost every website like to communicate with its users by automatic emails for example
“Registration Details”. “drop Password”
“. So you need to have some kind of mechnisim to create by mental act a template for each telecommunicate type visually and ordain able to parse them before sending.
I have worked on this on some communicate and i thought it may be helpful for others.
These are the methods we need to implement in our Data Access Layer.
Only the last method is tricky so i am adding its proceedure as come up.
act proc [dbo].[EmailTemplate_GetTemplateVariableValue]( @tablename varchar(100). @handle varchar(100). @pkey varchar(100). @pkeyValue varchar(100))as
exec(’select ‘ + @field + ‘ from ‘ + @tablename +’ Where ‘ + @pkey + ‘=’ + @pkeyValue )
Just be to cover the DAL methods or its up to you how you handle them.
Model. EmailTemplate template = BLL. EmailTemplateLoad(templateid);
ReplaceVariables(template. EmailTemplateID template. BodyText valuesCollection);
(EnumModel. VariableType). EnumModel. VariableType. Password. ToString())))
mailbody. regenerate(matches[i]. Value password);
(EnumModel. VariableType). EnumModel. VariableType. go out. ToString())))
(EnumModel. VariableType). EnumModel. VariableType. Time. ToString())))
(EnumModel. VariableType). EnumModel. VariableType. DateTime. ToString())))
(EnumModel. VariableType). EnumModel. VariableType. Encrypted. ToString())))
mailbody. regenerate(matches[i]. Value. Common. Utility. EncryptString(fieldValue));
(tablename. Trim(). Length > 0 && handle. cut(). Length > 0)
BLL. GetTemplateVariableValue(tablename field pkey pkeyValue.
public class EnumModel{// Here you need to specify the TemplateKey column value from EmailTemplate Tablepublic enum EmailTempate{Header,Footer,NewsLetter,UserRegisteration,ForgotPassword,MassEmal,ProfileApproved,}
//Possible Variable Types are handled in parser but if needed can be supported more public enum VariableType{Password = 1,Date = 2,measure = 3,DateTime = 4,Encrypted = 5,}//This is a ClassMemberName from EmailVariable Tablepublic enum VariableClassMemberName{SubscriberID,UserId,PackageId,StatusID,CompanyID,}}
Here Header and Footer are EmailTemplates but can be treated as a Variable to be included in other emails for consistent layout of all templates desire if you want to undergo a radiate banner and some links on the top and copyrights statement on furnish of every template then instead of doing this in all templates just create a Header and Footer template and just add a variable in each template and it ordain automatically placed there. In this way you act as many sections of your each template as you would like to.
I undergo designed the UI for editing the template just like following but its up to you how you create by mental act the UI.
System. Collections. Specialized. NameValueCollection values = new System. Collections. Specialized. NameValueCollection(); values. Add(EnumModel. VariableClassMemberName. UserId. ToString() user. UserID. ToString());
say that in above label we are adding the determine of UserId whose password needs to be sent.
Now call the Parser. analyse method to get the bodytext for email.
arrange mailBody=Parser. analyse(forgotPasswordEmailId values);
finally write some your own label to displace email with this mail body :)
Filed under: | Tagged: .
XHTML: You can use these tags: <a href="" call=""> <abbr call=""> <acronym call=""> <b> <blockquote cite=""> <have in mind> <code> <del datetime=""> <em> <i> <q cite=""> <touch> <strong>
Forex Groups - Tips on Trading
Related article:
http://safeery2k.wordpress.com/2007/11/15/generic-email-templates/
comments | Add comment | Report as Spam
|