Cannot send email from Sales order

Im trying send an email from the Sales order form with the sales order custom print format. But its showing following error

"TypeError: attach_print() got an unexpected keyword argument 'html'"

When i try with no attachment the mail goes through. please help me out thanks.

### App Versions

{
“automobile_sales”: “0.0.1”,
“erpnext”: “14.0.0-dev”,
“frappe”: “15.0.0-dev”,
“hrms”: “1.0.0”
}

### Route

Form/Email Queue/75

### Trackeback

Traceback (most recent call last):
File “apps/frappe/frappe/app.py”, line 56, in application
response = frappe.api.handle()
File “apps/frappe/frappe/api.py”, line 53, in handle
return _RESTAPIHandler(call, doctype, name).get_response()
File “apps/frappe/frappe/api.py”, line 69, in get_response
return self.handle_method()
File “apps/frappe/frappe/api.py”, line 79, in handle_method
return frappe.handler.handle()
File “apps/frappe/frappe/handler.py”, line 45, in handle
data = execute_cmd(cmd)
File “apps/frappe/frappe/handler.py”, line 83, in execute_cmd
return frappe.call(method, **frappe.form_dict)
File “apps/frappe/frappe/init.py”, line 1589, in call
return fn(*args, **newargs)
File “apps/frappe/frappe/email/doctype/email_queue/email_queue.py”, line 378, in send_now
record.send()
File “apps/frappe/frappe/email/doctype/email_queue/email_queue.py”, line 135, in send
message = ctx.build_message(recipient.recipient)
File “apps/frappe/frappe/email/doctype/email_queue/email_queue.py”, line 294, in build_message
message = self.include_attachments(message)
File “apps/frappe/frappe/email/doctype/email_queue/email_queue.py”, line 353, in include_attachments
print_format_file = frappe.attach_print(**attachment)
TypeError: attach_print() got an unexpected keyword argument ‘html’

### Request Data

{
“type”: “POST”,
“args”: {
“name”: 75
},
“btn”: {
“0”: {},
“length”: 1
},
“headers”: {},
“error_handlers”: {},
“url”: “/api/method/frappe.email.doctype.email_queue.email_queue.send_now”
}

### Response Data

{
“exception”: “TypeError: attach_print() got an unexpected keyword argument ‘html’”
}

Morning

Does other emails go out? Is this only related to SO-emails?

1 Like

Other mails goes out. Its only with attach

Good morninig

Hi Could you please help me out. im working on production environment and need to enable this feature

Anyupdates

Good day

Could you please be a little more specific about the information you are supplying

Does other emails go out? Is this only related to SO-emails?

Your answer was

Other mails goes out. Its only with attach

What I am suggesting by way of my question is that you look at other doctypes
i.e. Purchase Innvoice with / without attachement.

You also mention that you have a custom print format ?
Did you try and send a mail with a std-print format?

It would help those trying to assist, if you supply some more information about what
you have tried e.g. send mail with / without attachment. Send mail with std / non-std
print format.

1 Like

I had checked with standard and non standard both outputs are same will check again and update you. Thanks for the reply.

I checked with purchase and sales invoice both are giving the same error. I tried with standard and custom print format , both are giving the same error. It’s a production environment and there are custom apps.

With out print attach option the email goes through.

“TypeError: attach_print() got an unexpected keyword argument ‘html’”

Also in the attachment header.

Please attached images for your reference.
Please let me know if anything can be done on this issue. Thanks in advance.




Check for error logs.

1 Like

Which error log should be checked. I checked worker.error.log which is logging the same error output

Traceback (most recent call last):
  File "/home/amccevhash/frappe-bench/env/lib/python3.10/site-packages/rq/worker.py", line 1075, in perform_job
    rv = job.perform()
  File "/home/amccevhash/frappe-bench/env/lib/python3.10/site-packages/rq/job.py", line 854, in perform
    self._result = self._execute()
  File "/home/amccevhash/frappe-bench/env/lib/python3.10/site-packages/rq/job.py", line 877, in _execute
    result = self.func(*self.args, **self.kwargs)
  File "/home/amccevhash/frappe-bench/apps/frappe/frappe/utils/background_jobs.py", line 172, in execute_job
    method(**kwargs)
  File "/home/amccevhash/frappe-bench/apps/frappe/frappe/email/doctype/email_queue/email_queue.py", line 184, in send_mail
    record.send(is_background_task=is_background_task, smtp_server_instance=smtp_server_instance)
  File "/home/amccevhash/frappe-bench/apps/frappe/frappe/email/doctype/email_queue/email_queue.py", line 135, in send
    message = ctx.build_message(recipient.recipient)
  File "/home/amccevhash/frappe-bench/apps/frappe/frappe/email/doctype/email_queue/email_queue.py", line 294, in build_message
    message = self.include_attachments(message)
  File "/home/amccevhash/frappe-bench/apps/frappe/frappe/email/doctype/email_queue/email_queue.py", line 353, in include_attachments
    print_format_file = frappe.attach_print(**attachment)
TypeError: attach_print() got an unexpected keyword argument 'html'

Which error log should be checked. I checked worker.error.log which is logging the same error output.
Please help me out thanks in advance

Traceback (most recent call last):
  File "/home/amccevhash/frappe-bench/env/lib/python3.10/site-packages/rq/worker.py", line 1075, in perform_job
    rv = job.perform()
  File "/home/amccevhash/frappe-bench/env/lib/python3.10/site-packages/rq/job.py", line 854, in perform
    self._result = self._execute()
  File "/home/amccevhash/frappe-bench/env/lib/python3.10/site-packages/rq/job.py", line 877, in _execute
    result = self.func(*self.args, **self.kwargs)
  File "/home/amccevhash/frappe-bench/apps/frappe/frappe/utils/background_jobs.py", line 172, in execute_job
    method(**kwargs)
  File "/home/amccevhash/frappe-bench/apps/frappe/frappe/email/doctype/email_queue/email_queue.py", line 184, in send_mail
    record.send(is_background_task=is_background_task, smtp_server_instance=smtp_server_instance)
  File "/home/amccevhash/frappe-bench/apps/frappe/frappe/email/doctype/email_queue/email_queue.py", line 135, in send
    message = ctx.build_message(recipient.recipient)
  File "/home/amccevhash/frappe-bench/apps/frappe/frappe/email/doctype/email_queue/email_queue.py", line 294, in build_message
    message = self.include_attachments(message)
  File "/home/amccevhash/frappe-bench/apps/frappe/frappe/email/doctype/email_queue/email_queue.py", line 353, in include_attachments
    print_format_file = frappe.attach_print(**attachment)
TypeError: attach_print() got an unexpected keyword argument 'html'

meanwhile you can check this post.

to access the error log from the awsombar type error log.
Check for title send_mail within the error log

have checked the same. iam not facing any other issues with pdf or other. Just the issue with attach option. Also i have a working daily report for HR which pulls out the report in HTML and send a daily auto email. Which works fine. I dont understand what is the problem with New email option in docs. Both of my instances are doing the same .

Traceback with variables (most recent call last):
  File "apps/frappe/frappe/utils/background_jobs.py", line 172, in execute_job
    method(**kwargs)
      site = 
      method = <function send_mail at 0x7f907984bf40>
      event = None
      job_name = '<function send_mail at 0x7f5cede3d480>'
      kwargs = {'email_queue_name': 80, 'is_background_task': True}
      user = 'Administrator'
      is_async = True
      retry = 0
      method_name = 'send_mail'
  File "apps/frappe/frappe/email/doctype/email_queue/email_queue.py", line 184, in send_mail
    record.send(is_background_task=is_background_task, smtp_server_instance=smtp_server_instance)
      email_queue_name = 80
      is_background_task = True
      smtp_server_instance = None
      record = <EmailQueue: 80>
  File "apps/frappe/frappe/email/doctype/email_queue/email_queue.py", line 135, in send
    message = ctx.build_message(recipient.recipient)
      self = <EmailQueue: 80>
      is_background_task = True
      smtp_server_instance = None
      ctx = <frappe.email.doctype.email_queue.email_queue.SendMailContext object at 0x7f9079793f10>
      message = None
      recipient = <EmailQueueRecipient: e5ca5bf4dd parent=80>
  File "apps/frappe/frappe/email/doctype/email_queue/email_queue.py", line 294, in build_message
    message = self.include_attachments(message)
      self = <frappe.email.doctype.email_queue.email_queue.SendMailContext object at 0x7f9079793f10>
      recipient_email = '
      message = 'Content-Type: multipart/mixed; boundary="===============7365307873322280950=="\r\nMIME-Version: 1.0\r\nMessage-Id: <167928753577.1769.15337746728316750127>\r\nX-Original-From: Administrator \r\nSubject: Re: Your order is out for delivery! (#SAL-ORD-16-03-2023-00001-1)\r\nFrom: Administrator <support@>\r\nTo: sup\r\nDate: Mon, 20 Mar 2023 04:45:35 -0000\r\nReply-To: s\r\nX-Frappe-Site: https://\r\n\r\n--===============7365307873322280950==\r\nContent-Type: multipart/alternative; boundary="===============1540292893071558506=="\r\nMIME-Version: 1.0\r\n\r\n--===============1540292893071558506==\r\nContent-Type: text/plain; charset="utf-8"\r\nMIME-Version: 1.0\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n [View this in your browser](https:///Sales\r\nOrder/SAL-ORD-16-03-2023-00001-1?format=3DStandard&key=3Dda5efd4a3ab6eb38e1=\r\n40e3433db1c6c00)\r\n\r\n\r\n\r\nLeave this conver...
  File "apps/frappe/frappe/email/doctype/email_queue/email_queue.py", line 353, in include_attachments
    print_format_file = frappe.attach_print(**attachment)
      self = <frappe.email.doctype.email_queue.email_queue.SendMailContext object at 0x7f9079793f10>
      message = 'Content-Type: multipart/mixed; boundary="===============7365307873322280950=="\r\nMIME-Version: 1.0\r\nMessage-Id: <167928753577.1769.15337746728316750127@>\r\nX-Original-From: Administrator >\r\nSubject: Re: Your order is out for delivery! (#SAL-ORD-16-03-2023-00001-1)\r\nFrom: Administrator <su>\r\nTo: su\r\nDate: Mon, 20 Mar 2023 04:45:35 -0000\r\nReply-To: \r\nX-Frappe-Site: https://\r\n\r\n--===============7365307873322280950==\r\nContent-Type: multipart/alternative; boundary="===============1540292893071558506=="\r\nMIME-Version: 1.0\r\n\r\n--===============1540292893071558506==\r\nContent-Type: text/plain; charset="utf-8"\r\nMIME-Version: 1.0\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n [View this in your browser](https:///Sales\r\nOrder/SAL-ORD-16-03-2023-00001-1?format=3DStandard&key=3Dda5efd4a3ab6eb38e1=\r\n40e3433db1c6c00)\r\n\r\n\r\n\r\nLeave this conver...
      message_obj = <email.message.EmailMessage object at 0x7f907972c790>
      attachments = [{'print_format': 'Standard', 'html': '', 'doctype': 'Sales Order', 'name': 'SAL-ORD-16-03-2023-00001-1', 'lang': 'en', 'print_letterhead': '1'}]
      attachment = {'print_format': 'Standard', 'html': '', 'doctype': 'Sales Order', 'name': 'SAL-ORD-16-03-2023-00001-1', 'lang': 'en', 'print_letterhead': '1'}
      file_filters = {}
builtins.TypeError: attach_print() got an unexpected keyword argument 'html'

have checked the same. iam not facing any other issues with pdf or other. Just the issue with attach option. Also i have a working daily report for HR which pulls out the report in HTML and send a daily auto email. Which works fine. I dont understand what is the problem with New email option in docs. Both of my instances are doing the same .

Please give me some guidance , as im novice to erpnext thanks

Traceback with variables (most recent call last):
  File "apps/frappe/frappe/utils/background_jobs.py", line 172, in execute_job
    method(**kwargs)
      site = 
      method = <function send_mail at 0x7f907984bf40>
      event = None
      job_name = '<function send_mail at 0x7f5cede3d480>'
      kwargs = {'email_queue_name': 80, 'is_background_task': True}
      user = 'Administrator'
      is_async = True
      retry = 0
      method_name = 'send_mail'
  File "apps/frappe/frappe/email/doctype/email_queue/email_queue.py", line 184, in send_mail
    record.send(is_background_task=is_background_task, smtp_server_instance=smtp_server_instance)
      email_queue_name = 80
      is_background_task = True
      smtp_server_instance = None
      record = <EmailQueue: 80>
  File "apps/frappe/frappe/email/doctype/email_queue/email_queue.py", line 135, in send
    message = ctx.build_message(recipient.recipient)
      self = <EmailQueue: 80>
      is_background_task = True
      smtp_server_instance = None
      ctx = <frappe.email.doctype.email_queue.email_queue.SendMailContext object at 0x7f9079793f10>
      message = None
      recipient = <EmailQueueRecipient: e5ca5bf4dd parent=80>
  File "apps/frappe/frappe/email/doctype/email_queue/email_queue.py", line 294, in build_message
    message = self.include_attachments(message)
      self = <frappe.email.doctype.email_queue.email_queue.SendMailContext object at 0x7f9079793f10>
      recipient_email = ''
      message = 'Content-Type: multipart/mixed; boundary="===============7365307873322280950=="\r\nMIME-Version: 1.0\r\nMessage-Id: <167928753577.1769.15337746728316750127>\r\nX-Original-From: Administrator <>\r\nSubject: Re: Your order is out for delivery! (#SAL-ORD-16-03-2023-00001-1)\r\nFrom: Administrator <s>\r\nTo: \r\nDate: Mon, 20 Mar 2023 04:45:35 -0000\r\nReply-To: \r\nX-Frappe-Site: https://\r\n\r\n--===============7365307873322280950==\r\nContent-Type: multipart/alternative; boundary="===============1540292893071558506=="\r\nMIME-Version: 1.0\r\n\r\n--===============1540292893071558506==\r\nContent-Type: text/plain; charset="utf-8"\r\nMIME-Version: 1.0\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n [View this in your browser](https:///Sales\r\nOrder/SAL-ORD-16-03-2023-00001-1?format=3DStandard&key=3Dda5efd4a3ab6eb38e1=\r\n40e3433db1c6c00)\r\n\r\n\r\n\r\nLeave this conver...
  File "apps/frappe/frappe/email/doctype/email_queue/email_queue.py", line 353, in include_attachments
    print_format_file = frappe.attach_print(**attachment)
      self = <frappe.email.doctype.email_queue.email_queue.SendMailContext object at 0x7f9079793f10>
      message = 'Content-Type: multipart/mixed; boundary="===============7365307873322280950=="\r\nMIME-Version: 1.0\r\nMessage-Id: <167928753577.1769.15337746728316750127@>\r\nX-Original-From: Administrator <>\r\nSubject: Re: Your order is out for delivery! (#SAL-ORD-16-03-2023-00001-1)\r\nFrom: Administrator <s>\r\nTo: \r\nDate: Mon, 20 Mar 2023 04:45:35 -0000\r\nReply-To: r\nX-Frappe-Site: https://\r\n\r\n--===============7365307873322280950==\r\nContent-Type: multipart/alternative; boundary="===============1540292893071558506=="\r\nMIME-Version: 1.0\r\n\r\n--===============1540292893071558506==\r\nContent-Type: text/plain; charset="utf-8"\r\nMIME-Version: 1.0\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n [View this in your browser](https:///Sales\r\nOrder/SAL-ORD-16-03-2023-00001-1?format=3DStandard&key=3Dda5efd4a3ab6eb38e1=\r\n40e3433db1c6c00)\r\n\r\n\r\n\r\nLeave this conver...
      message_obj = <email.message.EmailMessage object at 0x7f907972c790>
      attachments = [{'print_format': 'Standard', 'html': '', 'doctype': 'Sales Order', 'name': 'SAL-ORD-16-03-2023-00001-1', 'lang': 'en', 'print_letterhead': '1'}]
      attachment = {'print_format': 'Standard', 'html': '', 'doctype': 'Sales Order', 'name': 'SAL-ORD-16-03-2023-00001-1', 'lang': 'en', 'print_letterhead': '1'}
      file_filters = {}
builtins.TypeError: attach_print() got an unexpected keyword argument 'html'

Update : I cannot find a solution for this nor i could reach to code error. What i did was updated to the latest version the issue is resolved.