Sending Using a Role Object

The Mezzanine ID e-mail address associated with the Identity will automatically be used.

persistent object Doctor{...}
void mailToIdentity(Doctor d){
    Mez:email(d, "email.descriptionKey", "email.subjectKey", "email.bodyKey");


void mailAttachments(Doctor d){
   Mez:email(d, "email.descriptionKey", "email.subjectKey", "/jasper/report1/master.jxrml");

Note that it is possible to send emails with optional attachments. Html tags (<table>,<br>,<h2>,<b>,...) can be used to format text.

Sending to an Arbitrary Email address

persistent object Patient {
    string emailAddress;
void mailToAddress(Patient p){
    Mez:email(p.emailAddress, "email.descriptionKey", "email.subjectKey", "email.bodyKey");

Specifying Custom Report Filenames

Additionally if more flexible naming is required for the emailed reports, there exists an additional syntax that specifies a "naming" function. In this case use Mez:emailAttach which also takes these naming functions as arguments as in the excerpt below. The naming function is a 0-arg function that returns a string that will be run when the report is generated/emailed. A function can be specified for each report, or the same function can be specified multiple times. A single report "pair" can be specified or multiple.

string myNamingFunctionTwo() {
	return "Trainee_Workout_Report_No_Two";

string myNamingFunction() {
	return "Trainee_Workout_Report_No_One";

void mailWorkouts() {
	Trainee uTrainee = Trainee:user();
	string traineeFname = uTrainee.fname;
	string traineeSname = uTrainee.sname;
	string traineeUUID = uTrainee._id;
	Mez:emailAttach(, "email_desc.trainee_workouts_report", "email_subject.trainee_workouts_report", "email_body.trainee_workouts_report", 
	{"trainee-workouts-report/trainee_workouts_report.jrxml", myNamingFunction()}, 
	{"trainee-workouts-report/trainee_workouts_report_two.jrxml", myNamingFunctionTwo()});

Specifying Custom Email Templates

To change the layout, images or colours of the e-mail for e.g. custom branding purposes, a final enum parameter can be added to the Mez:email or Mez:emailAttach BIFs to specify a custom (html) e-mail template. The enumerated type is EMAIL_TEMPLATES, with the specified enum member the html file name (without the extension), as included by the developer under the web-app/email-templates directory. Images for this template is to be included under web-app/images, and prefixed by "cid" in the html.

DSL snippet
Mez:email(emailAddress, "input.email_subject_static", "input.email_subject_static", "input.email_body_static", EMAIL_TEMPLATES.myEmailTemplate);
web-app/email-templates/myEmailTemplate.html snippet
<img alt="logo" width="190" height="61" src="cid:myCustomLogo.png" />

Please note that it is not mandatory to have the email-template folder. If one is not included the original default email template in service will be used to send messages. 

To override this behaviour you can include just one template called "default.html" which will then be used for all the mails instead of the original "default" template. Just including the file will enable the behaviour without you having to explicitly mention the template when the email syntax is used. More customization will require you to indicate the template you want to use via above mentioned enumeration. 

└── web-app
    ├── email-templates
    │   └── myEmailTemplate.html
    └── images
        └── myCustomLogo.png

Please refer to the default e-mail template as an example or starting point for your custom template: email_template.html. Note that it contains ${subject}, ${body} and ${applicationInstanceName} placeholders that are replaced at runtime. In essence these placeholders should always be standard and included in any variation of custom template you introduce.