Reputation: 11
I need to compose an email body and have user name password atributes to be added of every user to it. For now i have the html content in a string and im trying to have string formatter to replace the user name and password for the respective user. How ever I am having trouble having the html content in a single string and also get the mapping of diferent users to be changed accordingly.
code snipet
String regEmailBody =
"<div>
+ "successfully registered for the system. <br>Your username "
+ "is[@email_placeholder].<br>Your temporary password is <b>"
+ "@sysGeneratedPW_placeholder!</b><br>Please login to the system to reset your password, "
+ "click on the button below.<br></p></div>";
regEmailBody.replaceFirst("@name_placeholder", name);
regEmailBody.replaceAll("@userEmail", emailAdd);
Upvotes: 0
Views: 50
Reputation: 696
Strings in java are immutable. In your code, you are producing new strings with replaced parts, but you are not storing them anywhere.
regEmailBody = regEmailBody.replaceFirst("@name_placeholder", name);
(the example code are also missing a " after the div, and the placeholder strings does not correspond with what you're trying to replace.)
Upvotes: 1