Hi folks,
I’m not sure if my subject line is correct, but here is my issue.
In my handler I announce an interception. My interception point performs some checks and then calls another function in the interceptor, passing data from the checks.
function dispatchEmail(user,partner,contact,group){
log.debug("--------start dispatch email-----------");
//set email view
rc.emailView = “emails/testsend”;
//set email layout based on partnerid
rc.emailBody = getPlugin(“Renderer”).renderLayout("#partner.getPartnerKey()#/Layout.#partner.getPartnerKey()#.Email");
//Get new mail object
rc.mail = mailService.newMail().config(from="#arguments.user.getName()# via #getSetting(‘email’).from#",
replyto=getSetting(‘email’).replyto,
to="#arguments.contact.getEmail()#",
type=“html”,
subject=“Test email send”,
server=getSetting(‘email’).server,
port=getSetting(‘email’).port,
username=getSetting(‘email’).username,
password=getSetting(‘email’).password,
priority=“5”);
//create email tokens
rc.tokens = {contact_name=arguments.contact.getName(),
contact_firstname=arguments.contact.getFirstName(),
user_firstname=arguments.user.getFirstName(),
user_name=arguments.user.getName(),
contact_email=arguments.contact.getEmail()};
//set email tokens
rc.mail.setBodyTokens(rc.tokens);
//set body of email
rc.mail.setBody(rc.emailBody);
// Send the mail
results = mailService.send(rc.mail);
log.debug("--------end dispatch email-----------");
}
When renderLayount tries to execute I get an error saying that rc.emailView is undefined. I’m guess this is the case because dispatchEmail doesn’t have access to the request collection, and emailView hasn’t been appended. In order to fix this would I just pass the event argument of my interception point to the dispatchEmail function or is there another way I can get access to rc from within dispatchEmail and append email view?
Thanks.
Nolan