Frappe Email: Sending calendar icv file as an inline attachment


I am using frappe.sendmail to send calendar invitation emails. The aim is to get the calendar event automatically added to the recipient’s calendar. I am following to achieve that.

I am facing a couple of issues :-

  1. I need to set the attachment’s content-type header to text/calendar and when I do that, frappe.sendmail uses MimeText that messes up the newline characters in the original calendar text (iCalendar). The relevant code seems to be Is there a way to override this ?

  2. Is there a way to add custom headers to an email attachment ? I need to customise the headers to match the above document.