Click here to Skip to main content
15,891,704 members
Articles / Web Development / HTML

Email Templates

Rate me:
Please Sign up or sign in to vote.
4.51/5 (44 votes)
29 Jul 2007CPOL6 min read 292.1K   8.1K   170  
In this article, I am going to consider the process of managing and sending emails inside a .NET application.
Imports System
Imports System.Collections

Namespace TemplateParser.Modificators

    ' Abstract class for Modificators
    Public MustInherit Class Modificator
        Protected _parameters As New Hashtable()

        Public ReadOnly Property Parameters() As Hashtable
            Get
                Return _parameters
            End Get
        End Property

        Public MustOverride Sub Apply(ByRef Value As String, ByVal ParamArray Parameters() As String)
    End Class

    Class NL2BR
        Inherits Modificator

        Public Overrides Sub Apply(ByRef Value As String, ByVal ParamArray Parameters() As String)
            Value = Value.Replace(ControlChars.Lf, "<br>")
        End Sub
    End Class

    Class HTMLENCODE
        Inherits Modificator

        Public Overrides Sub Apply(ByRef Value As String, ByVal ParamArray Parameters() As String)
            Value = Value.Replace("&", "&amp;")
            Value = Value.Replace("<", "&lt;")
            Value = Value.Replace(">", "&gt;")
        End Sub
    End Class

    Class UPPER
        Inherits Modificator

        Public Overrides Sub Apply(ByRef Value As String, ByVal ParamArray Parameters() As String)
            Value = Value.ToUpper()
        End Sub
    End Class

    Class LOWER
        Inherits Modificator

        Public Overrides Sub Apply(ByRef Value As String, ByVal ParamArray Parameters() As String)
            Value = Value.ToLower()
        End Sub
    End Class

    Class TRIM
        Inherits Modificator

        Public Overrides Sub Apply(ByRef Value As String, ByVal ParamArray Parameters() As String)
            Value = Value.Trim()
        End Sub
    End Class

    Class TRIMEND
        Inherits Modificator

        Public Overrides Sub Apply(ByRef Value As String, ByVal ParamArray Parameters() As String)
            Value = Value.TrimEnd()
        End Sub
    End Class

    Class TRIMSTART
        Inherits Modificator

        Public Overrides Sub Apply(ByRef Value As String, ByVal ParamArray Parameters() As String)
            Value = Value.TrimStart()
        End Sub
    End Class

    Class [DEFAULT]
        Inherits Modificator

        Public Overrides Sub Apply(ByRef Value As String, ByVal ParamArray Parameters() As String)
            If Value Is Nothing Or Value.Trim() = String.Empty Then
                Value = Parameters(0)
            End If
        End Sub
    End Class

End Namespace

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
Ukraine Ukraine
Alexander is freelance web developer with 4 years experience. He has skills in ASP.NET/MS SQL Server, PHP/MySQL, Ruby On Rails, XHTML, CSS. You can contact with me by seigo.ua@gmail.com. Also check my homepage at www.klalex.com.

Comments and Discussions