Use the sendAt property to specify when to send the emails (in UNIX timestamp seconds, not milliseconds):
const msg = {
to: 'recipient@example.org',
from: 'sender@example.org',
subject: 'Hello delayed email',
html: '<p>Some email content</p>',
sendAt: 1500077141,
};
await sgMail.send(msg);- Emails can only be scheduled, at most, 72 hours in advance.
- If successful, without a
batchIdset, the call tosgMail.send()returns a 202 status code with an empty response body. Currently, cancelling a scheduled email without abatchIdset requires a change of password or contacting our support team.
- Create a Batch ID.
- Assign Batch ID to a
msgobject:
const msg = {
to: 'recipient@example.org',
from: 'sender@example.org',
subject: 'Hello delayed email',
html: '<p>Some email content</p>',
sendAt: 1500077141,
batchId: 'YOUR_BATCH_ID'
};
await sgMail.send(msg);- Update your Batch ID with a
cancelorpausestatus.