Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.codenullapp.com/llms.txt

Use this file to discover all available pages before exploring further.

Features

  • Send emails to any recipient with a custom subject and message.
  • Attach files as Blob or File objects.
  • Authorization token support for secure API calls.

Function Overview

The sendEmailAsync function sends an email using a POST request to the email service endpoint. It supports the following parameters:

Parameters

ParameterTypeRequiredDescription
tostringYesRecipient’s email address.
subjectstringYesSubject of the email.
messagestringYesBody of the email.
fromstringNoSender’s email address. Defaults to the configured sender address.
attachmentsArray of objectsNoList of attachments to include in the email.
Attachment Object Each attachment in the attachments array should have the following properties:
PropertyTypeRequiredDescription
filenamestringYesThe name of the file to be attached.
fileBlob or FileYesThe binary content of the file.

Usage Example

1. Sending an Email Without Attachments

helpers.sendEmailAsync({
  to: 'recipient@example.com',
  subject: 'Hello!',
  message: 'This is a simple email without attachments.',
})
  .then((response) => {
    console.log('Email sent successfully:', response);
  })
  .catch((error) => {
    console.error('Error sending email:', error);
  });

2. Sending an Email with Attachments using Blob file

// example file
const file = new Blob(['This is the content of the file.'], { type: 'text/plain' });
  
helpers.sendEmailAsync({
  to: 'recipient@example.com',
  subject: 'Hello!',
  message: 'This is a simple email without attachments.',
   attachments: [
        {
          filename: 'example.txt',
          file, // Binary content of the file
        },
      ],
})
  .then((response) => {
    console.log('Email sent successfully:', response);
  })
  .catch((error) => {
    console.error('Error sending email:', error);
  });

3. Sending an Email with Attachments using Binary Content

// example file
 // Create binary content (e.g., a Uint8Array or Blob)
  const binaryContent = new Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100]); // "Hello World"
  const file = new Blob([binaryContent], { type: 'application/octet-stream' });
  
helpers.sendEmailAsync({
  to: 'recipient@example.com',
  subject: 'Hello!',
  message: 'This is a simple email without attachments.',
   attachments: [
        {
          filename: 'example.txt',
          file, // The binary file
        },
      ],
})
  .then((response) => {
    console.log('Email sent successfully:', response);
  })
  .catch((error) => {
    console.error('Error sending email:', error);
  });

Documentation for Sending Emails with Base64 Attachments (backend, hooks)

This guide explains how to use the sendEmail function to send emails with PDF attachments in base64 format.

  const doc = new jsPDF();
  doc.text('Hello world!', 10, 10);
  const pdfCreated = doc.output('datauristring');
  
   const archivoPDF = {
        filename: `filename.pdf`,
        content: pdfCreated.split('base64,')[1],
        encoding: 'base64'
    };
    const optionsEmail = {       
        to: `email@email.com`,
        subject: 'subject',
        message: 'message',
        attachments: [archivoPDF]
    }
    await sendEmail(optionsEmail);

    export { sendEmail };

Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question. Perform an HTTP GET request on the current page URL with the ask query parameter:
GET https://codenull.gitbook.io/dev/configurations/integrations/sending-emails-with-attachments-in-your-application-frontend.md?ask=<question>
The question should be specific, self-contained, and written in natural language. The response will contain a direct answer to the question and relevant excerpts and sources from the documentation. Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.