Actually i have the one company table :-

db.define_table(('comany'),
                     Field('cowner_id'),
                     Field('details'),
                     Field('due_date','date'))

here i want to send the mail with the details by using the cron when the 
date will match to the due date :-

i have the following code in my modules send.py :-

from gluon.tools import Mail
mail=Mail()
#specify server
mail=auth.settings.mailer
mail.settings.server='smtp.gmail.com:587'
mail.settings.login='[email protected]:password'
#specify address to send as
mail.settings.sender='[email protected]'
#send the message
try:
     import datetime
     list[]
     currentdate = datetime.date.today()
     for row in db(db.company.due_date == currentdate).select():
          list.append(details)
     mail.send(to=[row.cowner_id],
    subject='Sending the mail by using Cron job',
    message=str(list))
except Exception, e:
print 'oops: %s' % e    

here the problem is the if the i have many companies in our database than 
how i sent the different mail to each of the different companies at a time 
with all details when the due_date will match to the each of the companies. 
here the for loop scope is ended so that is the reason to it is sending and 
taking the only last data from my database and if i sent the mail by using 
inside the scope of the for loop than the for each of the rows mail will be 
sent with the details so its frustrated that is the reason i want to sent 
the only one mail with all the details to the companies with date which 
matches the today's date. But if the more than one companies in our 
database than it is taking only the last because scope of for loop is ended 
so how i resolve these issues please help me.

Reply via email to