Notification on email sent

I tried to create a notification that tell me after an email is sent. But got warning that notifications can’t be set on Email Queue.
How can I do this? Thank you for any help.

note: this is not to set up a notification via email. but on the email sent itself (notif will be sent to Slack).

Hey,
Maybe you can combine email sending and notification creation to work sequentially ? we can make the sendmail to complete instead of queueing by setting delayed=False, and after the email is triggered we could have the system notification or in your case slack notification created.

        if email:
            frappe.sendmail(
                recipients=[email],
                subject=subject,
                message=message,
                **delayed=False,**
            )

        if not frappe.db.exists(
            "Notification Log",
            {"subject": subject, "document_name": doc.name, "for_user": user_id},
        ):
            frappe.get_doc(
                {
                    "doctype": "Notification Log",
                    "subject": subject,
                    "email_content": message,
                    "type": "Alert",
                    "document_type": doc.doctype,
                    "document_name": doc.name,
                    "for_user": user_id,
                }
            ).insert(ignore_permissions=True)

Thank you for your suggestion. I will try it first.

1 Like