BACK
|Examples

Odoo: Send email via python code within Odoo

Sometimes you way to send an email via code instead of using the Odoo's built-in email functionality. I was able to the following python code snippet to achieve that.

mail_pool = env['mail.mail']
values={}

values.update({'subject': subject})
values.update({'email_to': 'example@email.com'})
values.update({'body_html': html})
#values.update({'body': record })
msg_id = mail_pool.create(values)
And then call send function of the mail.mail
if msg_id:
  mail_pool.send([msg_id])

Want to stay in the loop?

Sign up for Newsletter
© Copyright 2022 All rights reserved. A blog by Rubeshan.com.