Trying to override the InboundMail Class

Hi Team,
I’m trying to override the InboundMail class to achieve some more functionalities, Could anyone ever do this, if so I’d like to get some idea on this.

We have customized the Task Doctype and added some fields where the employee is set to mandatory. So whenever I receive an email I want to create a Task and in the employee field I wanna assign someone from our account team. So for this, I would need to override the InboundMail Class.

@Robot Please Refer This Address Doctype Class Override is refrence for how to override your inboundmail class

1 Like

Hi @Meet Thanks for your response.

I’ve tried this but it isn’t working, because Address is a doctype so we would override like this but InboundMail is just a class right?
That’s why it’s not working I guess.

There could be other to override this

@Robot Please Check This Document for write custom code to override class function

1 Like

Yeah, I’ve tried Monkey Patch @Meet. It is working.

from frappe.email.receive import InboundMail

from ss_custom_erpnext.ss_custom_erpnext.email.receive import CustomInboundMail

InboundMail._create_reference_document = CustomInboundMail._create_reference_document

I’ve added like this in my custom app init file