3 Ways to Send Emails with dynamic content in ASP.NET

To send email from asp.net application, we have followed various approaches in past

1. Create & design HTML file, Use place holder to find and replace.

Pros:
If you are sending one type of email.
Easy to test the layout in different browsers.
Cons:
if you are sending multiple types of email but for email format or layout is same.
Difficult to maintain
Performance slow, due to disk read operation.
Difficult to Test in different browser with dynamic data.
2. Create XSLT file, transform by passing your custom object.

Pros: if you know xslt and only one type of email you want to send.
Cons:
Xslt knowledge is required
Difficult to maintain, If you have to send multiple type of dynamic email content with same email format or layout.
Very difficult to debug.
Some Performance hit.
3. Create two asp.net User controls, one master user control & one is child user control.

Master user control will be similar to asp.net master page. To keep email outer email body template in one location.
Child user control, for specific email. To send email, render your user control by applying master user control.
Pros:
Easy to maintain
Easy to debug
Easy to test in different browsers
we can use asp.net user controls like GridView, DataList, Repeater etc.
Cons:
No issues found so far in this approach yet. Will add here when found.
You can download the code sample that uses the User Control approach. You can leave your feedback or comments here or email me at anjum.rizwi@valtech.co.in.

Download Sample demo using asp.net user control

Comments

Popular posts from this blog

How to Fix Secure Connection Failed Error in Mozilla Firefox

PortQry solve your connectivity issues