我正在尝试将字符串附加到从Blob提取的JSON内容中。JSON内容类似于以下内容。
{
"Subject": "Details",
"FromAddress": "[email protected]",
"ToAddress": "[email protected]",
"Body": "My name is {name} and I faced this {exception} error"
}
在这种情况下,我必须附加一个名称(例如Arvind)和一个异常(例如SystemException),然后将格式化的数据发送到另一种方法来发送邮件
string data = EmailBlob.DownloadTextAsync().Result;
EmailData emailData = JsonConvert.DeserializeObject<EmailData>(data);
该变量data
包含以下JSON
{
"Subject": "Details",
"FromAddress": "[email protected]",
"ToAddress": "[email protected]",
"Body": "My name is {name} and I faced this {exception} error"
}
变量emailData保存以下内容。
Subject: "Details",
FromAddress: "[email protected]",
ToAddress: "[email protected]",
Body: "My name is {name} and I faced this {exception} error"
现在,我必须更新名称“ Arvind”和异常“ SystemException”,并将emaildata变量发送到另一种方法,如下所示。
Subject: "Details",
FromAddress: "[email protected]",
ToAddress: "[email protected]",
Body: "My name is Arvind and I faced this SystemException error"
如何使用C#.NET实现它?
EmailData.Body = EmailData.Body
.Replace("{name}", "Arvind")
.Replace("{exception}", "SystemException ");
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句