Hello,
I created a module to send a scheduled daily mail.
the mail is successfully sent.
But In mail, body does not appear correctly.
this is my code and the output
code:
def send_crm_report(self, cr, uid, ids=None, context=None):
message_obj = self.pool.get('mail.message') mail_mail = self.pool.get('mail.mail') mail_ids = [] today = datetime.now().strftime('%Y-%m-%d 00:00:00') par_id = message_obj.search(cr, uid, [('date', '>', today), ('model', '=', 'crm.lead') ]) if par_id:
try:
email_from = "crm@exemple.com" name = "Name" subject = "CRM Report" mail_ids.append(mail_mail.create(cr, uid, { 'email_to': "emna.hidri@gmail.com", 'subject': subject, 'body_html': '<table><tbody><tr><th style="width:135px">Vendeur</th><th style="width: 85px;">opportunite</td><th style="width: 125px;">Description</th></tr> % for row in message_obj.browse(cr, uid, par_id): <tr><td> ${row.author_id.name} </td><td style="text-align: center;"> ${row.subject or ''} </td><td> ${row.body or ''} </td></tr> %endfor <tbody><table>'
}, context=context)) mail_mail.send(cr, uid, mail_ids, context=context) except Exception, e:
print "Exception", e return None
output:
Vendeur opportunite Description
% for row in message_obj.browse(cr, uid, par_id):
${row.author_id.name} ${row.subject or } ${row.body or }%endfor
Thanks for reply