Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sending a scheduled email #205

Closed
jsgandalf opened this issue Feb 3, 2017 · 2 comments
Closed

Sending a scheduled email #205

jsgandalf opened this issue Feb 3, 2017 · 2 comments
Labels

Comments

@jsgandalf
Copy link

Quick Question,

Problem: I have tried numerous times to set a start_time to be scheduled in advance. However the result happens over and over, the email is always delivered immediately. This is not the result I'd expect, whats wrong with my code? :/

I've read the following documentation which allows you to send scheduled Emails:

https://developers.sparkpost.com/api/transmissions.html#header-options-attributes

Today is 2017-02-03, I'm setting 8 days in advance: 2017-02-11T08:00:00-04:00

function email(toEmail, campaignId, templateId, startTime){
  var transmission = {
    campaign_id: campaignId,
    content: {
      template_id: templateId
    },
    recipients: [{address: toEmail}]
  }
  , options = {
    start_time: '2017-02-11T08:00:00-04:00',
    num_rcpt_errors: 3
  };
  return sparky.transmissions.send(transmission, options);
}
@aydrian
Copy link
Contributor

aydrian commented Feb 3, 2017

Ah. I see what the problem is. There is an options for the transmission object. The start_time goes in there.
Try this:

function email(toEmail, campaignId, templateId, startTime){
  var transmission = {
    campaign_id: campaignId,
    content: {
      template_id: templateId
    },
    recipients: [{address: toEmail}],
    options = {
      start_time: '2017-02-11T08:00:00-04:00'
    }
  }
  , options = {
    num_rcpt_errors: 3
  };
  return sparky.transmissions.send(transmission, options);
}

@jsgandalf
Copy link
Author

@aydrian Thank you Thank you Thank you Thank you Thank you x10000!!!!!!!!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants