This commit is contained in:
Jonathan Jenne
2023-09-20 14:07:20 +02:00
12 changed files with 119 additions and 16 deletions

View File

@@ -2,6 +2,13 @@
Public Property EmailAdress As String
Public Property EmailSubject As String
Public Property EmailBody As String
Public Property ReferenceID As Integer
Public Property ReceiverName As String
Public Property SenderName As String
Public Property SenderAdress As String
Public Property SignatureLink As String
Public Property Message As String
End Class

View File

@@ -0,0 +1,59 @@
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>", ""},
{"<LINK_TO_DOCUMENT>", pEmailData.SignatureLink},
{"<MESSAGE>", pEmailData.Message}
}
End Sub
Public Sub SetEmailBody(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

View File

@@ -6,4 +6,9 @@
Public Property Email As String
Public Property Language As String
Public ReadOnly Property FullName() As String
Get
Return Prename + " " + Name
End Get
End Property
End Class