The template would look like EMAIL_BODY_TEXT="Dear %s,
"
+ "In Referenece to our conversation on 12-12-1093, I would like to offer you a discount of %s "
+ "Hope u had a pleasant experience
"
+ "Thanks and Regards, "
+ "******* " . To call this , the code would be String message=String.format(EMAIL_BODY_TEXT,"xyz","123"); the value xyz and 123 are read from excel sheet. But I need to add $name which is linked to name column of excel sheet.
– dpkcsJun 12 '17 at 11:41
Possible duplicate: https://stackoverflow.com/questions/3655424/string-replacement-in-java-similar-to-a-velocity-template
– MarkusJun 12 '17 at 12:46
Thanks Markus, It helped a bit. But real issue is mapping of excel column .For example is there any way that I can link one column of table say emailId to ${emailId} of string subsr.?? Or I have to parse each row and give value at run time??
valuesMap.put("email", emailMetaData.getEmailId());
valuesMap.put("fname", emailMetaData.getFirstName());
valuesMap.put("lname", emailMetaData.getLastName());
valuesMap.put("ccode", emailMetaData.getCouponCode());
StrSubstitutor sub = new StrSubstitutor(valuesMap);
String EMAIL_BODY = sub.replace(emailBody);
– dpkcsJun 13 '17 at 04:53
" + "In Referenece to our conversation on 12-12-1093, I would like to offer you a discount of %s
" + "Hope u had a pleasant experience
" + "Thanks and Regards,
" + "******* " . To call this , the code would be String message=String.format(EMAIL_BODY_TEXT,"xyz","123"); the value xyz and 123 are read from excel sheet. But I need to add $name which is linked to name column of excel sheet. – dpkcs Jun 12 '17 at 11:41