[Coldbox 4]

Hi All,
Trying to use Luis example mailservice.

Having problems with the renderer not being found.
I’m using the code as is from https://github.com/coldbox-modules/cbox-mailservices/wiki/Usage
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’)
,to = ‘ken.caldwell@sswahs.nsw.gov.au’
,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

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=“myemail@email.com”} // Pass any variables to view, e.g. #args.email#
)
);

`

I hope that helps.

Helped heaps, Thanks