CodeMash
  • 🚀Backend as a service
  • 🦄Roadmap
  • 🍕Release Notes
  • Installation
    • Managed Service
    • 🏗️AWS-CDK
    • 🏗️Azure
    • 🏗️Docker
    • 🏗️GC
    • 🏗️Terraform
  • dashboard
    • CodeMash Cloud
    • Project
    • Membership
      • Users
      • Roles
      • Policies
      • Triggers
      • Integrations
        • Apple
        • Azure
        • Facebook
        • Google
        • Twitter
      • Settings
    • Database
      • Collections
        • Schema
          • From Template
          • Structure
        • Tabs
        • Triggers
        • Indexes
        • Shared Forms
      • Taxonomies
        • Terms
        • Schema
        • Settings
      • Aggregation
      • Imports
      • Exports
      • Backups
    • Files
      • Integrations
        • CodeMash
        • S3 Bucket
    • Notifications
      • Push
        • Push Templates
        • Push Templates API
        • Push Notifications
        • Push Notifications API
        • Devices
        • Devices API
        • Integrations
          • Firebase
          • One Signal
          • Expo
      • Email
        • Email Templates
        • Emails
        • Integrations
          • AWS SES
          • Twilio Sendgrid
          • Mailgun
      • 🏗️Server events
      • 🏗️Sms
    • Payments
      • Integrations
        • Apple Pay
        • Google Pay
        • Stripe
        • Kevin.
        • Paysera
        • Decta
    • Scheduler
    • Logs & Monitoring
    • Code
      • Functions
        • Function Inputs
        • Function Templates
          • Node.js
          • Python
          • Ruby
          • Java
          • Go
          • .NET Core
      • CodeMash Functions
        • Google Functions
          • Google Calendar
          • Google Gmail
        • Microsoft Functions
          • Microsoft 365 Users
          • Microsoft 365 Calendar
        • Collection Find
        • Collection Update
        • Users Find
        • Image Resize
        • Html To Pdf
        • Word Document
        • Barcode
        • QR Code
        • Send Email
        • Send Notification
        • Email Reminder
        • Notification Reminder
      • Integrations
        • AWS Lambda
        • Google Cloud Functions
        • Azure Functions
  • Other Topics
    • Apple
      • Developer Portal
      • Bundle Identifier
      • Team ID
      • Service ID
      • Key ID
    • Triggers
    • Tokens Binding
      • Project Tokens
      • Initiator Tokens
      • Receiver Tokens
      • Request Tokens
      • Operation based tokens
      • Template Functions
    • Search parameters
      • Paging
      • Filter
      • Sort
      • Projection
    • data-models
    • Errors
  • SDK
    • Node.js
    • TypeScript
    • .NET
    • 🏗️Go Lang
    • 🏗️Flutter
    • 🏗️Swift
    • 🏗️Kotlin
  • CLI
    • 🏗️CodeMash CLI
  • API
    • Get Started
    • Prerequisites
    • How to test?
    • Cors
    • Project
    • Membership
      • Authentication
      • Users
    • Database
      • Collections
        • Aggregate
        • Change Responsibility
        • Count
        • Delete
        • Delete Many
        • Distinct
        • Find
        • Find One
        • Insert
        • Insert Many
        • References
        • Replace
        • Update
        • Update Many
      • Taxonomies
        • Find
    • Files
    • Code
    • Notifications
      • Push
      • Emails
      • Server Events
      • 🏗️Sms
    • Payments
    • Scheduler
    • Logs & Monitoring
Powered by GitBook
On this page
  • Creating a template
  • Tokens
  • Predefined functions

Was this helpful?

Edit on GitHub
  1. dashboard
  2. Notifications
  3. Email

Email Templates

Overview of email templates

PreviousEmailNextEmails

Last updated 4 years ago

Was this helpful?

Email templates let you define the structure of your email messages.

Creating a template

Navigate to the email templates list by selecting on Email Module from the left menu bar and then selecting Templates from a sub-menu. Then press Add New.

Here you provide a template name which is essentially a way to identify templates for yourself. Also, a subject is a subject for an email message and a body that is a body for an email message. Additionally, you can provide code and email account to use for sending this template.

Body mode can be swapped between the source (HTML) and editor modes. Shown above is an editor mode that displays how your message will look to a recipient. Change to source mode to edit HTML code.

Also, everything written in source mode is considered to be inside HTML <body> tags. Though you can still use <style> tags.

Tokens

To use dynamic data in your templates you can use a @Model object. This object will be injected with all of your tokens passed in send request and additionally some predefined tokens.

In the example above there is a token Project.Name used in multiple places. It is a predefined token that corresponds to your project's name. Before an email is sent, this value will be replaced with your project's name and instead Welcome to @Model.Project.Name! recipient will see something like Welcome to CodeMash! .

Writing tokens is supported in:

  • Subject

  • Code

  • Body

If you wish to write some logic, you can do that in Code block. All the code you write in this block will be attached to your body, so you can use variables defined in the code block inside your body. Although all of this code can also be written inside the body block, it was just separated into distinct code from body.

Example of a code block

@{
    var goodDecision = "Bad Decision";
    if (@Model.Favourite.Color == "purple") {
        goodDecision = "Good Decision";
    }
}

Example of the body block

This is a token directly injected into body: @Model.Direct.Token
This is a token from code block: @goodDecision

You can also write code in your body block:
@{
    var bodyVariable = @Model.Direct.Token;
}

And then use it just like variables from code: @bodyVariable

Tokens use Razor syntax. So your subject, code, and body blocks must be a valid razor code.

More about how to use tokens follow the link below.

There are some already predefined functions that can be used to ease the use of tokens.

Predefined functions

There are some built-in functions that can be used to ease the use of tokens.

Tokens Binding
Template Functions
New email template page with example data