I am trying to append a string to the JSON content extracted from a blob. The JSON content is similar to below.
{
"Subject": "Details",
"FromAddress": "[email protected]",
"ToAddress": "[email protected]",
"Body": "My name is {name} and I faced this {exception} error"
}
In this, I have to append a name (e.g. Arvind) and an exception (e.g. SystemException) and send the formatted data to another method to send mail
string data = EmailBlob.DownloadTextAsync().Result;
EmailData emailData = JsonConvert.DeserializeObject<EmailData>(data);
The variable data holds the following JSON
{
"Subject": "Details",
"FromAddress": "[email protected]",
"ToAddress": "[email protected]",
"Body": "My name is {name} and I faced this {exception} error"
}
The variable emailData holds the below.
Subject: "Details",
FromAddress: "[email protected]",
ToAddress: "[email protected]",
Body: "My name is {name} and I faced this {exception} error"
Now I have to update the name 'Arvind' and exception 'SystemException' and send the emaildata variable to another method as below.
Subject: "Details",
FromAddress: "[email protected]",
ToAddress: "[email protected]",
Body: "My name is Arvind and I faced this SystemException error"
How could I achieve it using C#.NET?
Body.Replace("{name}","Arvind")string data = EmailBlob.DownloadTextAsync().Result;should beawaitingthis