Versions Compared
Version | Old Version 6 | New Version 7 |
---|---|---|
Changes made by | Former user |
|
Saved on |
Key
- This line was added.
- This line was removed.
- Formatting was changed.
Table of Contents |
---|
Sending Using a Role Object
The Mezzanine ID e-mail address associated with the Identity will automatically be used.
Code Block |
---|
@Role("Doctor") persistent object Doctor{...} |
Code Block |
---|
void mailToIdentity(Doctor d){ Mez:email(d, "email.descriptionKey", "email.subjectKey", "email.bodyKey"); } |
or
Code Block |
---|
void mailAttachments(Doctor d){ Mez:email(d, "email.descriptionKey", "email.subjectKey", "/jasper/report1/master.jxrml"); } |
Info |
---|
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
Code Block |
---|
persistent object Patient { string emailAddress; } |
Code Block |
---|
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.
Code Block | ||||
---|---|---|---|---|
| ||||
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(uTrainee.email, "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.
Code Block | ||||
---|---|---|---|---|
| ||||
Mez:email(emailAddress, "input.email_subject_static", "input.email_subject_static", "input.email_body_static", EMAIL_TEMPLATES.myEmailTemplate); |
Code Block | ||||
---|---|---|---|---|
| ||||
<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.
No Format |
---|
└── 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.
Excerpt | ||
---|---|---|
| ||
Mez:email | Mez:emailAttach |