[coldbox-3.8] MailService BodyTokens

17 views
Skip to first unread message

Yieng

unread,
Dec 6, 2016, 12:54:45 AM12/6/16
to ColdBox Platform
Hi,

In MailService we are able to set body token and use these values on the view (content of email body). Currently the only values that can be set on the body tokens are simple, i.e. not array, structs, etc.
My question: Is it possible to assign a complex value to the body token, e.g. an array, struct, rc collection and use them on the view that render the email body content?

Here's an example to illustrate:

In a handler method that handles the email send out:
local.email.setBodyTokens({
  stInfo = stReportInfo
}

In the view (for email body content):
loop through @stInfo@??

I know the answer is most likely 'no', but I want to check to see if it's possible. Thanks.

Yieng.

br...@bradwood.com

unread,
Dec 6, 2016, 1:24:42 AM12/6/16
to col...@googlegroups.com
You can do this, but not with the tokens.  Create a view for the E-mail body and use renderView() to generate the view.  Pass in the bits you need directly via view args so you don't pollute you rc or prc. Then set the returned HTML directly into the E-mail.
 
Here you can see something similar going on in ContentBox CMS.
 

Thanks!

~Brad

ColdBox/CommandBox Developer Advocate
Ortus Solutions, Corp

E-mail: br...@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com 
 
 
--------- Original Message ---------
--
--
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
For News, visit http://blog.coldbox.org
For Documentation, visit http://wiki.coldbox.org
For Bug Reports, visit https://ortussolutions.atlassian.net/browse/COLDBOX
---
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to coldbox+u...@googlegroups.com.
To post to this group, send email to col...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/coldbox/3856f826-4eb2-43ed-a50d-498182b5ee59%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Yieng

unread,
Dec 6, 2016, 6:34:38 PM12/6/16
to ColdBox Platform
Thanks Brad! Will try out your suggestion.

Yieng

unread,
Dec 8, 2016, 7:22:45 PM12/8/16
to ColdBox Platform
Thanks Brad!

Success! This is what I used:

In a handler method that gather the info and sends out the email (partial):

stInfo = {};
stInfo.firstname = "John";
stInfo.lastname = "Doe";
/* etc, etc...*/

mail.setBody( renderer.renderView( view='the email view file', args= stInfo ));

Then in the email view file, i reference the local variables as:

 args.<local variable name>
e.g.
 args.firstname
 args.lastname
Reply all
Reply to author
Forward
0 new messages