I think this is one of the hardest problems im dealing with in my app, i have installed moment.js (using mrt). and what i want to do is let the user pick a date and a time that the server will send an email to that user friends. so for example: now is thursday 9:13 pm and the user want to send the message monday at 6:47 am. and after the user have set the time i want the email to be sent repeatedly every week at the day and time that the user have set. so i thought using moment.js like that (client side):
var now = moment(); (the current date and time).
then use a datepicker like jqueryui or a common one, and a timepicker,for setting the time and date that the user selected like that(client side):
var day = user selection using datepicker;
var time = user selection using timepicker;
var result = moment.set(day,time);
insert the result to the database:
DateToSendEmail.insert({date:result});
and finally have the code to really execute the Email.send function (on the server side):
var DateToSend = DateToSendEmail.findOne({});
var thisMoment = moment();
if(DateToSend === thisMoment){
Email.send({
to:[friends]
from:"myApplication@xxx.com"
Subject:"auto email send"
html:"auto email send"
});
}
the one thing that i don't know is whether it will work if the user isnt entering the the app for along time (lets say a month) or should i use Meteor.setInterval to execute this function repeatedly?