我想编辑一个文本,其中有一些动态字段,所以我使用替换方法将这些字段放在上下文中的特殊位置。我的问题是当我想在上下文中替换这些字段时,它给了我一个错误:输入字符串的格式不正确。错误发生在 EmailBody 中。Body 变量的内容是这样的:
FROM: {JournalAbbreviation} < {JournalAbbreviation}@test.com><br />
SUBJECT: Review Submitted Successfully for {JournalAbbreviation}<br />
BODY:<br />
Manuscript ID: {ManuscriptID}<br />
Title: {Title}<br />
<br />
<br />
Dear {Prefix} {Firstname} {Middlename} {Lastname},<br />
<br />
Thank you for your review for {JournalAbbreviation}. We appreciate your time and feedback and hope to collaborate with you again in the near future.<br />
<br />
Kind regards,<br />
{FirstnameSender}, PhD<br />
Associate Editor<br />
{JournalFullName}<br />
http://{JournalAbbreviation}.test.com<br />
<br />
此代码已保存为数据库中的字符串,并用这些代码填充正文变量。
Body = Body.Replace("{Prefix}", "{0}");
Body = Body.Replace("{Firstname}", "{1}");
Body = Body.Replace("{Middlename}", "{2}");
Body = Body.Replace("{Lastname}", "{3}");
Body = Body.Replace("{ManuscriptID}", "{4}");
Body = Body.Replace("{Title}", "{5}");
Body = Body.Replace("{JournalAbbreviation}", "{6}");
Body = Body.Replace("{FullJournalName}", "{7}");
Body = Body.Replace("{PrefixSender}", "{8}");
Body = Body.Replace("{FirstnameSender}", "{9}");
Body = Body.Replace("{MiddlenameSender}", "{10}");
Body = Body.Replace("{LastnameSender}", "{11}");
string **EmailBody** = String.Format(Body, Prefix, Firstname, Middlename, Lastname, ManuscriptID, Title, JournalAbbreviation, FullJournalName, PrefixSender, FirstnameSender, MiddlenameSender, LastnameSender);
打印出来的是:
发件人:IEEE < IEEE@test.com> 主题:提交给 IEEE 的评论
手稿 ID:102-IEEE-2013 标题:使用双聚类方法进行文本挖掘 International Electrical Engineering
约翰史密斯博士,
已对上述手稿进行了审查。
亲切的问候,国际电气工程 http://IEEE.test.com
任何机构可以帮助我找到问题吗?谢谢