sendEmailFromTemplate method

Future<MessageStatus?> sendEmailFromTemplate(
  1. String templateName,
  2. EmailEnvelope envelope, {
  3. Map<String, String>? templateValues,
  4. List<String>? attachments,
})

Implementation

Future<MessageStatus?> sendEmailFromTemplate(
    String templateName, EmailEnvelope envelope,
    {Map<String, String>? templateValues, List<String>? attachments}) async {
  Map<String, dynamic> parameters = {
    'templateName': templateName,
    'addressed': envelope.to,
    'cc-addresses': envelope.cc,
    'bcc-addresses': envelope.bcc,
    'criteria': envelope.query,
    'uniqueEmails': envelope.uniqueEmails,
  };

  if (attachments?.isNotEmpty ?? false) {
    parameters['attachments'] = attachments;
  }

  if (templateValues?.isNotEmpty ?? false) {
    parameters['template-values'] = templateValues;
  }

  return await Invoker.post('/emailtemplate/send', parameters);
}