我正在使用dictonary在电子邮件中执行合并代码替换通知电子邮件工作得很好但是由于某种原因,我有一段时间与网址没有将查询字符串添加到网址,即使网址很好形成。
Dictionary<string, string> stringsToReplace = new Dictionary<string, string>();
stringsToReplace.Add("{method}", method);
stringsToReplace.Add("{full_name}", fullname);
stringsToReplace.Add("{ipaddress}", GetIPAddress());
stringsToReplace.Add("{query}", queryMessage);
stringsToReplace.Add("{address}", address);
stringsToReplace.Add("{user_name}", fullname);
stringsToReplace.Add("{iva_ref}", caseRef);
stringsToReplace.Add("{case_ref}", caseRef);
stringsToReplace.Add("{optout}", OptionsText);
stringsToReplace.Add("{regemail}", OptionsText);
string linkreset = "<a href= '" + DomainUrl + "?email=" + customerEmail + "&uid=" + userId + "'> Reset Password" + "<a/>";
stringsToReplace.Add("{email}", customerEmail.ToString());
stringsToReplace.Add("{reset_link}", string.Format("Please click the link below to reset your password <br /> {0}", linkreset));
string verifyPassword = "<a href= '" + verificationUrl + "?email=" + customerEmail + "&uid=" + userId + "'> Verify Password" + "<a/>";
stringsToReplace.Add("{verification_link}", string.Format("Please click the link below to verify your password <br /> {0}", verificationUrl));
bodyMessage = bodyMessage.MultipleReplace(stringsToReplace);
我只是不知道为什么我的参数者没有被带到verifyPassword当我看到它停在.aspx的url并且超链接中没有查询字符串
答案 0 :(得分:1)
我认为您的代码有问题;
string verifyPassword = "<a href= '" + verificationUrl + "?email=" + customerEmail + "&uid=" + userId + "'> Verify Password" + "<a/>";
stringsToReplace.Add("{verification_link}", string.Format("Please click the link below to verify your password <br /> {0}", verificationUrl));
看起来应该是
string verifyPassword = "<a href= '" + verificationUrl + "?email=" + customerEmail + "&uid=" + userId + "'> Verify Password" + "<a/>";
stringsToReplace.Add("{verification_link}", string.Format("Please click the link below to verify your password <br /> {0}", verifyPassword ));
注意 - verifyPassword不是替换中的vertificationUrl。