ERPNext Foundation ERPNext Cloud User Manual Blog Discuss Frappé* Donate

CC and BCC in Sending Email via custom script


#1

I am having trouble with putting cc & bcc options while sending e-mail.
This is the code which is working fine (without cc and bcc):

frappe.call({
      method: "frappe.core.doctype.communication.email.make",
      args: {
      recipients: "my_email@mail.com",
      content: d,
      subject: "Test",
      doctype: "Panel",
      name: cur_frm.doc.name,
      send_email: 1,
      communication_medium: "Email",
      },
      async: false,
      callback: function(rh){
        console.log("mail sent")
      }
     });

After I tracked the parameters in developer’s tool, got to know that format is like this:

recipients:
cc:
bcc:

But its not working via custom script.

Can anyone help me is there any other event which I can use to send mail or I’m missing something


#2

Hello @nikzz

Did you get how to send mail in cc via custom script. i tried but did’t get mail in cc.


#3

Naah, didn’t found any way. Guess we need to parse through backend script for hiw it is actually getting and then can approach for the same


#4

How did you pass cc and bcc? Can you share your code example?

This should work

frappe.call({
	method: "frappe.core.doctype.communication.email.make",
	args: {
		recipients: "my_email@mail.com",
		cc: "cc@mail.com",
		bcc: "bcc@mail.com",
		content: d,
		subject: "Test",
		doctype: "Panel",
		name: cur_frm.doc.name,
		send_email: 1,
		communication_medium: "Email",
	},
	async: false,
	callback: function(rh){
	  console.log("mail sent")
	}
});


#5

@netchampfaris

Where should one put this code ??


#6

That’s exactly what I tried but didn’t worked


#7

No errors? Traceback? How are you debugging it?


#8

Actually no error is occurring. but mail is only sent to email id in recipient, not to cc and bcc


#9

Hi guys

Where should I put this custom script?


#10

I tried it on my local and it worked. No errors.


#11

Where should I add this script to be able.to test it ??


#12

Hi @olamide_shodunke

Trust you’re cool. Looks to me like a standard method so you should be able to call it from the client side by just creating a regular ‘Custom Script’ from the UI. You would probably need some event (like the click of a button) to call the method. The arguments are hard-coded in the example above but they’ll probably be dynamically selected from fields in the doctype in an actual implementation

Cheers