// Build email link
confirmLink = Master.siteDomain + \"/newsLetter.aspx?action=confirm&e=\" + emailAddress + \"&code=\" + verCode;
The Replace method returns a new, updated string. You need to assign the results of the Replace
call back to emailBody
:
emailBody = emailBody.Replace("[CONFIRMATION_LINK]", confirmLink);
It's because Replace does not edit the emailBody
variable. It returns the resultant string. In this case, you'd need:
string bodyToSend = emailBody.Replace("[CONFIRMATION_LINK]", confirmLink);
emailer.sendEmail(emailAddress, Master.noReplyEmail, emailSubj, bodyToSend);
Strings are immutable. String operation generally return new string instances. Try this:
emailBody = emailBody.Replace("[CONFIRMATION_LINK]", confirmLink);
Strings in C# are immutable, meaning they cannot be changed once they are instantiated unless explicitly pointed to another string. What happens is that you are calling "Replace" without any variable to receive the string that returns.
Change the 2nd to the last line with this code:
emailBody = emailBody.Replace("[CONFIRMATION_LINK]", confirmLink);