// Build email link confirmLink = Master.siteDomain + "/newsLetter.aspx?action=confirm&e=" + emailAddress + "&code=" + verCode; using (sqlCommand cmd = new sqlCommand("SELECT newRegEmailBody,newRegEmailSubj FROM tblSiteSettings WHERE (isActive = 1)",Master.cn)) { sqlDataReader rdr = cmd.ExecuteReader(); if (rdr.Read()) { emailBody = rdr[0].ToString(); emailSubj = rdr[1].ToString(); } rdr.Close(); } emailBody.Replace("[CONFIRMATION_LINK]",confirmLink); emailer.sendEmail(emailAddress,Master.noReplyEmail,emailSubj,emailBody);
这一切似乎都很好,除了身体仍然出现在文本中的[CONFIRMATION_LINK],任何想法?
解决方法
字符串是不可变的.字符串操作通常返回新的字符串实例
尝试这个:
尝试这个:
emailBody = emailBody.Replace("[CONFIRMATION_LINK]",confirmLink);