BACK
|Tutorials

Odoo: Automated actions - Send email via Python code

Sending an email via python code is pretty straight forward. This is useful for someone who wants to customize their Odoo server actions.

#setup the HTML email boddy
html ="optional HTML tags to stylize the email body"
mail_pool = env['mail.mail']
#add the email subjects and other fields etc...
values={}
values.update({'subject': subject})
values.update({'email_to': 'send_to_this_email@example.com'})
values.update({'body_html': html})
msg_id = mail_pool.create(values)

# And then call send function of the mail.mail,
if msg_id:
  mail_pool.send(\[msg_id])

Alternatively, you can use the built-in "Send Email" option in the action to do.

If you found this useful, please leave a comment below.

Want to stay in the loop?

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