frm.email_doc is just a thin layer over the CommunicationComposer class. You can specify a few more parameters by creating a new instance of that directly:
If you want more functionality, it’s pretty straightforward to extend that class either client or server side.
the status is stuck with the “sending” attribute, and does not send…
besides, I can insert the recepient email and subject but the message body does not cooperate.
Yeah, if you want to set the message body this way, I think you’ll have to override the make method. Right now, the function doesn’t seem to do anything to set the message body.
As for getting stuck on sending, I doubt that has anything to do with the javascript. In any case, your code works fine on my system. Are you able to send emails manually?
Thaks, but this is for a server script.
If I were to use this direction, I rather using the mailto: workaround, so the user will be able to review the mail prior to sending it.
about the sending, I can’t really explain this, because when hitting the built in New Email button works fine. It’s when I use the originalfrm.email_doc() or the aforementioned emailList(frm,toAddress,sbjct,message) I get stuck with the following:
Hmm…that’s really weird. I can’t think of any reason why instantiating the object manually would be any different. Perhaps try eliminating parameter lines one by one to see if they work? Can you check the email queue to see if there are any error messages?
Well, as mentioned, I also tried using the original method by inserting frm.email_doc('Bla bla'); to the script (it is the only line of code after right now) and got the same result…
about the email queue:
Traceback (most recent call last):
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/background_jobs.py”, line 100, in execute_job
method(**kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/email/queue.py”, line 419, in send_one
frappe.get_doc(‘Communication’, email.communication).set_delivery_status(commit=auto_commit)
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 850, in get_doc
doc = frappe.model.document.get_doc(*args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 75, in get_doc
return controller(*args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 113, in init
self.load_from_db()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 156, in load_from_db
frappe.throw((“{0} {1} not found”).format((self.doctype), self.name), frappe.DoesNotExistError)
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 432, in throw
msgprint(msg, raise_exception=exc, title=title, indicator=‘red’, is_minimizable=is_minimizable, wide=wide, as_list=as_list)
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 411, in msgprint
_raise_exception()
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 365, in _raise_exception
raise raise_exception(msg)
frappe.exceptions.DoesNotExistError: Communication af0341fa54 not found
That’s noteworthy. The Communication doctype is the email “record”, which then gets transformed into a email queue doc on creation. I wish I had a clearer picture of what’s going on, but for some reason the communication doctype creation is failing. Anything in the browser console when you hit send?