[Coldbox 4]

34 views
Skip to first unread message

ken.ca...@sswahs.nsw.gov.au

unread,
Dec 1, 2016, 1:04:44 AM12/1/16
to ColdBox Platform
Hi All,
Trying to use Luis example mailservice.

Having problems with the renderer not being found.
Just changing the value to personalise it.

I don't understand how the rc.emailView is used.
But until I can get the renderer to work I can't go any further.

My actual code is as follows:

// Used by the email layout to render this e-mail's view
rc.emailView = 'notification/admin_notification';

// Create a new mail object
local.Email = mailService.newMail(
from = getSetting('sendEmailFrom')
,subject = 'A new Yaralla Wedding Photography Booking'
);
// Set tokens within the mail object. THe tokens will be evaluated
// by the ColdBox Mail Service. Any matching @key@ within the view
// will be replaced with the token's value
local.Email.setBodyTokens({
booking_list_id = booking.getBooking_List_Id()
,date_of_booking = dateTimeFormat(booking.getDate_Of_Booking(), "medium")
,attendees = booking.getAttendees()
,vehicles = booking.getVehicles()
,firstname = booking.getFirstName()
,surname = booking.getSurName()
,email = booking.getEmail()
,contact_phone1 = booking.getContact_Phone1()
,contact_phone2 = booking.getContact_Phone2()
,comments = booking.getComments()
});

// Add plain text email
local.Email.addMailPart(charset='utf-8',type='text/plain',body=local.Renderer.renderLayout("layout.email.plain"));

// Add HTML email
local.Email.addMailPart(charset='utf-8',type='text/html',body=local.Renderer.renderLayout("layout.email.html"));

// Send the email. MailResult is a boolean.
local.mailResult = mailService.send(local.Email);


Regards Ken

Ancient Programmer

unread,
Dec 1, 2016, 2:59:36 AM12/1/16
to ColdBox Platform
In your component, add mailservice and renderer.

property name="mailService" inject="mailService@cbmailservices";
property name="renderer" inject="provider:coldbox:renderer";


You need to call get() in order to use renderLayout()

// Add plain text email
local.Email.addMailPart(
charset="utf-8",
type="text/plain",
body=renderer.get().renderLayout( 
layout = "layouts/email/plain", // Specify to use layout from /layouts/email/plain.cfm
view = rc.emailView, // Specify to use view from /views/notification/admin_notification.cfm
args = {email="mye...@email.com"} // Pass any variables to view, e.g. #args.email#
)
);

I hope that helps.




ken.ca...@sswahs.nsw.gov.au

unread,
Dec 1, 2016, 5:49:05 PM12/1/16
to ColdBox Platform
Helped heaps, Thanks
Reply all
Reply to author
Forward
0 new messages