Code for send email via erpnext

hello community . I want to add a button to send emails to users . I know there is an option for this in all doctypes but I want to send a custom email. how to achieve this ? thank you .

@bahaou Hey Baha, this solution requires a custom app because you have to patch the CommunicationComposer prototype.

  • Use the built in Email Template doctype
  • Decide how you want to map the email template to the doctype so that the communication composer can load it. This really depends on your use case, but it could be per-user/per-doctype (most complex) to per-doctype. If you want to go with per-doctype, add a custom field on the Email Template doctype for mapping.
// include this in a file that is  in build.json and included in the app via
frappe.views.CommunicationComposer = frappe.views.CommunicationComposer.extend({
	set_email_template: function(val) {
                // or frappe.db.get_value for your API that gets the correct template
// you may need to do more based on your use case, this is just to get you started

Good luck!