TagoIO SDK for JavaScript and TypeScript
    Preparing search index...

    Class Sendgrid

    Hierarchy

    Index

    Constructors

    Methods

    Constructors

    Methods

    • Send email using Sendgrid integration

      Parameters

      Returns Promise<string>

      A promise that resolves to a success message

      This method requires Sendgrid API key. For enhanced security, it's strongly recommended to use TagoIO Secrets rather than hardcoding credentials.

      const sendgridService = new Services({ token: context.token }).sendgrid;
      const result = await sendgridService.send({
      from: "sender@company.com",
      to: "client@company.com",
      subject: "Reports",
      message: "Hello client, it's your report",
      sendgrid_api_key: "YOUR_SENDGRID_API_KEY"
      });
      console.log(result);
      // Using an array of recipients
      const result = await sendgridService.send({
      from: "sender@company.com",
      to: ["client1@company.com", "client2@company.com"],
      subject: "Reports",
      message: "Hello clients, it's your report",
      sendgrid_api_key: "YOUR_SENDGRID_API_KEY"
      });
      // Sending HTML content
      const result = await sendgridService.send({
      from: "sender@company.com",
      to: "client@company.com",
      subject: "Reports",
      html: "<p>Hello client, it's your <strong>report</strong></p>",
      sendgrid_api_key: "YOUR_SENDGRID_API_KEY"
      });
      // Using a template
      const result = await sendgridService.send({
      from: "sender@company.com",
      to: "client@company.com",
      template: { name: "my_template" },
      sendgrid_api_key: "YOUR_SENDGRID_API_KEY"
      });
      // Using attachment
      const html = "<h1>Hello World</h1>";
      const base64 = Buffer.from(html).toString("base64");
      const pdfService = new Services({ token: context.token }).pdf;
      const pdfBase64 = await pdfService.generate({ base64, options: {
      displayHeaderFooter: true,
      margin: {
      top: "1.5cm",
      right: "1.5cm",
      left: "1.5cm",
      bottom: "1.5cm",
      },
      }});

      const sendgridService = new Services({ token: context.token }).sendgrid;
      await sendgridService.send({
      from: "sender@company.com",
      to: "client@company.com",
      subject: "Reports",
      message: "Hello clients, it's your report",
      attachment: {
      archive: pdfBase64.result,
      type: "base64",
      filename: "report.pdf",
      },
      sendgrid_api_key: "YOUR_SENDGRID_API_KEY"
      });
    • Send email using Sendgrid integration

      Parameters

      Returns Promise<string>

      A promise that resolves to a success message

      This method requires Sendgrid API key. For enhanced security, it's strongly recommended to use TagoIO Secrets rather than hardcoding credentials.

      const sendgridService = new Services({ token: context.token }).sendgrid;
      const result = await sendgridService.send({
      from: "sender@company.com",
      to: "client@company.com",
      subject: "Reports",
      message: "Hello client, it's your report",
      sendgrid_api_key: "YOUR_SENDGRID_API_KEY"
      });
      console.log(result);
      // Using an array of recipients
      const result = await sendgridService.send({
      from: "sender@company.com",
      to: ["client1@company.com", "client2@company.com"],
      subject: "Reports",
      message: "Hello clients, it's your report",
      sendgrid_api_key: "YOUR_SENDGRID_API_KEY"
      });
      // Sending HTML content
      const result = await sendgridService.send({
      from: "sender@company.com",
      to: "client@company.com",
      subject: "Reports",
      html: "<p>Hello client, it's your <strong>report</strong></p>",
      sendgrid_api_key: "YOUR_SENDGRID_API_KEY"
      });
      // Using a template
      const result = await sendgridService.send({
      from: "sender@company.com",
      to: "client@company.com",
      template: { name: "my_template" },
      sendgrid_api_key: "YOUR_SENDGRID_API_KEY"
      });
      // Using attachment
      const html = "<h1>Hello World</h1>";
      const base64 = Buffer.from(html).toString("base64");
      const pdfService = new Services({ token: context.token }).pdf;
      const pdfBase64 = await pdfService.generate({ base64, options: {
      displayHeaderFooter: true,
      margin: {
      top: "1.5cm",
      right: "1.5cm",
      left: "1.5cm",
      bottom: "1.5cm",
      },
      }});

      const sendgridService = new Services({ token: context.token }).sendgrid;
      await sendgridService.send({
      from: "sender@company.com",
      to: "client@company.com",
      subject: "Reports",
      message: "Hello clients, it's your report",
      attachment: {
      archive: pdfBase64.result,
      type: "base64",
      filename: "report.pdf",
      },
      sendgrid_api_key: "YOUR_SENDGRID_API_KEY"
      });
    • Send email using Sendgrid integration

      Parameters

      Returns Promise<string>

      A promise that resolves to a success message

      This method requires Sendgrid API key. For enhanced security, it's strongly recommended to use TagoIO Secrets rather than hardcoding credentials.

      const sendgridService = new Services({ token: context.token }).sendgrid;
      const result = await sendgridService.send({
      from: "sender@company.com",
      to: "client@company.com",
      subject: "Reports",
      message: "Hello client, it's your report",
      sendgrid_api_key: "YOUR_SENDGRID_API_KEY"
      });
      console.log(result);
      // Using an array of recipients
      const result = await sendgridService.send({
      from: "sender@company.com",
      to: ["client1@company.com", "client2@company.com"],
      subject: "Reports",
      message: "Hello clients, it's your report",
      sendgrid_api_key: "YOUR_SENDGRID_API_KEY"
      });
      // Sending HTML content
      const result = await sendgridService.send({
      from: "sender@company.com",
      to: "client@company.com",
      subject: "Reports",
      html: "<p>Hello client, it's your <strong>report</strong></p>",
      sendgrid_api_key: "YOUR_SENDGRID_API_KEY"
      });
      // Using a template
      const result = await sendgridService.send({
      from: "sender@company.com",
      to: "client@company.com",
      template: { name: "my_template" },
      sendgrid_api_key: "YOUR_SENDGRID_API_KEY"
      });
      // Using attachment
      const html = "<h1>Hello World</h1>";
      const base64 = Buffer.from(html).toString("base64");
      const pdfService = new Services({ token: context.token }).pdf;
      const pdfBase64 = await pdfService.generate({ base64, options: {
      displayHeaderFooter: true,
      margin: {
      top: "1.5cm",
      right: "1.5cm",
      left: "1.5cm",
      bottom: "1.5cm",
      },
      }});

      const sendgridService = new Services({ token: context.token }).sendgrid;
      await sendgridService.send({
      from: "sender@company.com",
      to: "client@company.com",
      subject: "Reports",
      message: "Hello clients, it's your report",
      attachment: {
      archive: pdfBase64.result,
      type: "base64",
      filename: "report.pdf",
      },
      sendgrid_api_key: "YOUR_SENDGRID_API_KEY"
      });