Versions Compared
Version | Old Version 4 | New Version 5 |
---|---|---|
Changes made by | Former user |
Former user |
Saved on |
Key
- This line was added.
- This line was removed.
- Formatting was changed.
Emails and SMS
There are essentially four ways to send email messages:
- Sending to a single object instance that implements the Identity interface. The Mezzanine ID e-mail address associated with the Identity will automatically be used.
- Sending to an arbitrary e-mail address
An example for sending outgoing SMS is also included below.
Status | ||||
---|---|---|---|---|
|
Info |
---|
|
Additionally if more flexible naming is required for the emailed reports, there exists an additional syntax that specifies a "naming" function. This 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 E-mail 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 |
Mez (System) BIFs
These BIFs are accessed via the pseudo unit “Mez”
now
Returns the current time
Info |
---|
|
today
Returns the today's date
Info |
---|
|
alert
Displays an alert dialog in the UI with the given message
Info |
---|
|
log
Writes a log message with level INFO. The logging entry is saved in the __logging_log__ table of your application instance's schema. It will also be available via the Logging Service.
Info |
---|
|
warn
Writes a log message with level WARNING
Info |
---|
|
error
Writes a log message with level SEVERE
Info |
---|
|
userRole
Returns a string representation of the current logged in user role
Info |
---|
|
Math BIFs
These BIFs are accessed via the pseudo unit “Math”
pow
Raises the first argument to the power of the second argument
Info |
---|
int i = Math:pow(2, 8); |
sqrt
Calculates the square root of the argument
Info |
---|
decimal d = Math:sqrt(3); |
random
Generates a random decimal
Info |
---|
decimal r = Math:random(); |