60 lines
1.8 KiB
VB.net
60 lines
1.8 KiB
VB.net
Public Class EmailTemplate
|
|
Inherits BaseModel
|
|
|
|
Private _firstBodyTemplate As List(Of String)
|
|
|
|
Private _replaceDictionary As Dictionary(Of String, String)
|
|
|
|
Public Sub New(pState As State)
|
|
MyBase.New(pState)
|
|
|
|
InitTemplate()
|
|
End Sub
|
|
|
|
Private Sub InitTemplate()
|
|
_firstBodyTemplate = New List(Of String) From {
|
|
"Guten Tag, <NAME_RECEIVER>,",
|
|
"",
|
|
"<NAME_SENDER> hat Ihnen ein Dokument zum <SIGNATURE_TYPE> gesendet.",
|
|
"",
|
|
"Über den folgenden Link können Sie das Dokument einsehen: <LINK_TO_DOCUMENT>",
|
|
"",
|
|
"<MESSAGE>",
|
|
"",
|
|
"Mit freundlichen Grüßen",
|
|
"<NAME_SENDER>"
|
|
}
|
|
End Sub
|
|
|
|
Private Sub InitDictionary(pEmailData As EmailData)
|
|
_replaceDictionary = New Dictionary(Of String, String) From {
|
|
{"<NAME_RECEIVER>", pEmailData.ReceiverName},
|
|
{"<NAME_SENDER>", pEmailData.SenderName},
|
|
{"<SIGNATURE_TYPE>", "signieren"},
|
|
{"<LINK_TO_DOCUMENT>", pEmailData.SignatureLink},
|
|
{"<MESSAGE>", pEmailData.Message}
|
|
}
|
|
End Sub
|
|
|
|
Public Sub FillEmailBody(pEmailData As EmailData)
|
|
|
|
InitDictionary(pEmailData)
|
|
|
|
Dim resultBody As String = ""
|
|
|
|
For Each lineItem As String In _firstBodyTemplate
|
|
Dim oLineValue As String = lineItem
|
|
For Each dictItem As KeyValuePair(Of String, String) In _replaceDictionary
|
|
If oLineValue.Contains(dictItem.Key) Then
|
|
oLineValue = oLineValue.Replace(dictItem.Key, dictItem.Value)
|
|
|
|
End If
|
|
Next
|
|
resultBody += oLineValue + "<br/>"
|
|
Next
|
|
|
|
pEmailData.EmailBody = resultBody
|
|
|
|
End Sub
|
|
End Class
|