Check if the document is a Support Ticket or Issue
if doc.doctype in [‘Support Ticket’, ‘Issue’]:
demo_email = "demo@gmail.com"
# Prepare the email subject and body
subject = f"New {doc.doctype}: {doc.subject}"
message = f"""
A new {doc.doctype} has been created/updated:
Ticket/Issue ID: {doc.name}
Subject: {doc.subject}
Description: {doc.details}
Company: {doc.company}
Status: {doc.status}
Created By: {doc.owner}
To view the full details, visit the {doc.name}.
"""try:
# Send the email to demo
frappe.sendmail(
recipients=[demo_email],
subject=subject,
message=message,
sender="noreply@demo.com" # Customize the sender email
)
# Log success message
frappe.log_error(f"Email sent to {demo_email} for ticket {doc.name}")
except Exception as e:
# Log error message
frappe.log_error(f"Error sending email to {demo_email} for ticket {doc.name}: {str(e)}")
i need the users support tickets to be redirected to this demo email and can be viewed. this is my server script. i too the doc as support ticket