Hi
When i using frappe.sendmail in my .py I got error shows below
Traceback (most recent call last):
File "apps/frappe/frappe/app.py", line 68, in application
response = frappe.api.handle()
File "apps/frappe/frappe/api.py", line 55, in handle
return frappe.handler.handle()
File "apps/frappe/frappe/handler.py", line 31, in handle
data = execute_cmd(cmd)
File "apps/frappe/frappe/handler.py", line 68, in execute_cmd
return frappe.call(method, **frappe.form_dict)
File "apps/frappe/frappe/__init__.py", line 1208, in call
return fn(*args, **newargs)
File "apps/companyerp/companyerp/utils.py", line 148, in sal_dn_mail
subject=frappe._('notification'),
File "apps/frappe/frappe/__init__.py", line 555, in sendmail
inline_images=inline_images, header=header, print_letterhead=print_letterhead, with_container=with_container)
File "apps/frappe/frappe/email/queue.py", line 162, in send
print_letterhead=print_letterhead)
File "apps/frappe/frappe/email/queue.py", line 183, in add
email_queue = get_email_queue(recipients, sender, subject, **kwargs)
File "apps/frappe/frappe/email/queue.py", line 227, in get_email_queue
e.message = cstr(mail.as_string())
File "apps/frappe/frappe/email/email_body.py", line 254, in as_string
self.validate()
File "apps/frappe/frappe/email/email_body.py", line 187, in validate
self.recipients = [strip(r) for r in self.recipients]
File "apps/frappe/frappe/email/email_body.py", line 187, in <listcomp>
self.recipients = [strip(r) for r in self.recipients]
File "apps/frappe/frappe/email/email_body.py", line 71, in <genexpr>
recipients = filter(None, (strip(r) for r in recipients))
File "apps/frappe/frappe/utils/data.py", line 1489, in strip
return (val or "").replace("\ufeff", "").replace("\u200b", "").strip(chars)
AttributeError: 'tuple' object has no attribute 'replace'
Sounds like the array recipients which I send to function sendmail has issues.
This is what i did
recipients=[]
rec_doc=frappe.db.get_list('Has Role',filters={'Role': ['=','Stock User'],'parenttype':['=','User']},fields=['parent'])
for row in rec_doc:
recipients.append(frappe.db.get_value('User',row.parent,'email'))
Please let me know how to fix it.
Thanks a lot.