Autopopulate "To" Field in Email Dialog

How do I auto populate “To” field in Menu>Email using field values from the current doctype?

1 Like

@romexblue123

If you want custom field value in to field then add option Email in your custom field and it will populate without any code.

1 Like

@romexblue123 Please don’t forgot to mark this as solution if it works for you

Can you pass on a field value from a doctype wizard using fetch from? Also, the pop-up that opens up after you click on Email button on the bottom section of the doctype cannot be found in the customize form. Am I missing somehing here?

@romexblue123

function compose_mail(frm,inv,pdf,email_ids) {
    var composer = new frappe.views.CommunicationComposer({
        doc: inv,
        frm: frm,
        recipients: email_ids,
        subject: "Your Invoice : " + String(inv.name),
        attach_document_print: true,
    });
        composer.dialog.set_value('infra_pdf_template', pdf);
}

Try this.

2 Likes

if your field name is email OR email_id OR contact_email, it would auto populate the To (recepients) in doctype’s email dialog box