Frappe Email: Sending calendar icv file as an inline attachment

Hello,

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 https://docs.cronofy.com/developers/smart-invites/sending/ 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 behttps://github.com/frappe/frappe/blob/76ee35f8651bdbc48858f27efab2961537a72a10/frappe/email/email_body.py#L329. 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.

Thanks.