How to create program for sending mail automatically from openerp using python?
I have created openerp module. I am trying to send mail to a client, when client id is ge
If you want to send an HTML email, the only way I have found is to send an email template via a server action.
Once you have the template created, discover it's template id by viewing the template and seeing what the id parameter is in the URL.
Then create a new server action, set the object to match the template and set the type to python code. Insert the following code:
self.pool.get('email.template').send_mail(
cr, uid, , context['active_id'],True, context=context)
Replacing
with the appropriate template id.
Just explaining some of the other fields
context['active_id']
gives the current id of the lead/invoice/etc being used to create the template withTrue
forces the email to be sent immediately rather than adding it to the queue. It would be better to leave as False
but due to a bug in version 7, it can lose email addresses when being added to the queue.You can look in addons/email_template/email_template.py and search for the send_mail function for further information.