Frappe Version- 15.54.1
Erpnext Version- 15.50.0
Here is the sample mail I am trying to send->
def send_email_with_pdf_attachment():
try:
# Generate PDF (example using a print format)
pdf_content = frappe.get_print(
doctype=“Sales Invoice”, # Replace with your doctype
name=“SINV-0001”, # Replace with specific document name
print_format=“Standard”, # Replace with your preferred print format
as_pdf=True
)
# Prepare email
frappe.sendmail(
recipients=['recipient@example.com'],
subject='Email with PDF Attachment',
message='Please find attached the PDF document.',
attachments=[{
'fname': 'document.pdf',
'fcontent': pdf_content
}]
)
frappe.msgprint('Email sent successfully with PDF attachment')
except Exception as e:
frappe.log_error(f"Error sending email: {str(e)}")
frappe.msgprint(f'Error: {str(e)}')
The error I get when I execute this via console->
ERROR | Property: Invalid value for CSS Level 2.1 property: var(–gray-900) [14:3: color] |
---|---|
WARNING | Property: Unknown Property name. [64:2: word-wrap] |
WARNING | Property: Unknown Property name. [83:2: columns] |
WARNING | Property: Unknown Property name. [90:2: background-size] |
WARNING | Property: Unknown Property name. [98:2: object-fit] |
WARNING | Property: Unknown Property name. [110:2: -webkit-print-color-adjust] |
WARNING | Property: Unknown Property name. [158:2: word-break] |
Requirement-> I want to send email to my customer with some attachment daily, but I get this error when I add an attachment to the code, but without attachment, it is being sent with no issues.
The pdf_content is giving errors I suppose.
For a workaround there is frappe.utils.get_url. But I need the attachments as pdf