Thanks Dave.
I wrote code like below: But I am not sure how to schedule this. Could
you please guide me to configure this Scheduler (need bit more
elaborated steps). Thank you appreciate your help:
______________________
In Controller: SendEmail.py:
# -*- coding: utf-8 -*-
# try something like
from gluon.tools import Mail
def send_email():
mail = Mail()
#mail.settings.server = '
smtp.hitachiconsulting.com'
mail.settings.server = '
smtp.gmail.com:587'
mail.settings.sender = '
a...@example.com'
mail.settings.login = '
myto...@gmail.com:123'
x = mail.send(
to = ['
m...@gmail.com'], subject = 'hello',
reply_to = '
a...@example.com',
message = 'Hello ! How are you?'
)
if x:
nm="Sent Successfully";
else:
nm="failed";
_____________
In Controller: scheduler.py
from gluon.scheduler import Scheduler
# schedule recurring tasks:
def sched_tasks(arg1=""):
# arg1 keeps this from being expose as a web page
# instantiate Scheduler class
scheduler = Scheduler(db)
task = scheduler.queue_task("send_email", period = 86400, repeats=1)
# show on console, or add to log
print task
db.commit()
def stop_tasks(arg1=""):
# arg1 keeps this from being expose as a web page
# instantiate Scheduler class
scheduler = Scheduler(db)
task = scheduler.task_status(db.scheduler_task.task_name == 'send_email')
if hasattr(task, "status") and task.status in ["QUEUED", "RUNNING"]:
stop = scehduler.stop_task(task.uuid)
# show on console or add to log
print cue
db.commit()
_____________________________
Please suggest me, next what I have to do , to schedule sending emails
1 to 15 days and 16 to 30 days .
Regards,
MC
> --
> Resources:
> -
http://web2py.com
> -
http://web2py.com/book (Documentation)
> -
http://github.com/web2py/web2py (Source code)
> -
https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
web2py+un...@googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.