Skip to content
Snippets Groups Projects
Commit 62853dfd authored by srosse's avatar srosse
Browse files

OO-527: use the variables in the context of mail template too

parent 8f92faae
No related branches found
No related tags found
No related merge requests found
...@@ -164,7 +164,7 @@ public class MailerWithTemplate { ...@@ -164,7 +164,7 @@ public class MailerWithTemplate {
if (recipientsTO != null) { if (recipientsTO != null) {
for (Identity recipient : recipientsTO) { for (Identity recipient : recipientsTO) {
// populate velocity context with variables // populate velocity context with variables
VelocityContext context = new VelocityContext(); VelocityContext context = getContext(template);
template.putVariablesInMailContext(context, recipient); template.putVariablesInMailContext(context, recipient);
sendWithContext(context, mCtxt, metaId, recipient, template, sender, result); sendWithContext(context, mCtxt, metaId, recipient, template, sender, result);
if (!result.getFailedIdentites().contains(recipient)) { if (!result.getFailedIdentites().contains(recipient)) {
...@@ -177,7 +177,7 @@ public class MailerWithTemplate { ...@@ -177,7 +177,7 @@ public class MailerWithTemplate {
List<Identity> cc = new ArrayList<Identity>(); List<Identity> cc = new ArrayList<Identity>();
cc.add(recipient); cc.add(recipient);
// populate velocity context with variables // populate velocity context with variables
VelocityContext context = new VelocityContext(); VelocityContext context = getContext(template);
template.putVariablesInMailContext(context, recipient); template.putVariablesInMailContext(context, recipient);
sendWithContext(context, mCtxt, metaId, recipient, template, sender, result); sendWithContext(context, mCtxt, metaId, recipient, template, sender, result);
} }
...@@ -191,6 +191,13 @@ public class MailerWithTemplate { ...@@ -191,6 +191,13 @@ public class MailerWithTemplate {
return result; return result;
} }
private VelocityContext getContext(MailTemplate template) {
if(template != null && template.getContext() != null) {
return new VelocityContext(template.getContext());
}
return new VelocityContext();
}
/** /**
* may return null, but then the result.getReturnCode != OK... so check the * may return null, but then the result.getReturnCode != OK... so check the
* result code. * result code.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment