Basically you're wanting to build a mail merge. I've done this in the past by setting up a dictionary where the key represents the mail merge parameter and the value represents the value needed to be injected into the body. I tended to wrap the keys in square brackets but you could use curly brackets like in your String.Format style.
Take a look at this example:
Code:
Private Function ReplaceMailMerge(body As String) As String
Dim supportedMailMergeParameters = New Dictionary(Of String, String)() From {
{"Mail Merge 1", "Foo"},
{"Mail Merge 2", "Bar"},
{"Etc", "Etc..."}
}
For Each supportedMailMergeParameter In supportedMailMergeParameters
Dim mailMergeParameter = $"{{{supportedMailMergeParameter.Key}}}"
Dim mailMergeValue = supportedMailMergeParameter.Value
body = body.Replace(mailMergeParameter, mailMergeValue)
Next
Return body
End Function
Using that Function would turn this string:
Code:
Oh {Mail Merge 1}, can I just get a {Mail Merge 2} or {Etc}
Into this:
Code:
Oh Foo, can I just get a Bar or Etc...
Live Demo: https://dotnetfiddle.net/9rpDwB