Skip to content

Latest commit

 

History

History
38 lines (30 loc) · 1.42 KB

scheduled-send.md

File metadata and controls

38 lines (30 loc) · 1.42 KB

Creating a Scheduled Send

Use the sendAt property to specify when to send the emails (in UNIX timestamp seconds, not milliseconds):

const msg = {
  to: '[email protected]',
  from: '[email protected]',
  subject: 'Hello delayed email',
  html: '<p>Some email content</p>',
  sendAt: 1500077141,
};

await sgMail.send(msg);

Limitations

  1. Emails can only be scheduled, at most, 72 hours in advance.
  2. If successful, without a batchId set, the call to sgMail.send() returns a 202 status code with an empty response body. Currently, cancelling a scheduled email without a batchId set requires a change of password or contacting our support team.
  1. Create a Batch ID.
  2. Assign Batch ID to a msg object:
const msg = {
  to: '[email protected]',
  from: '[email protected]',
  subject: 'Hello delayed email',
  html: '<p>Some email content</p>',
  sendAt: 1500077141,
  batchId: 'YOUR_BATCH_ID'
};

await sgMail.send(msg);
  1. Update your Batch ID with a cancel or pause status.