I have created a workbook using xlwt, now I was wondering if I could send an email using this workbook, but a without saving the workbook on disk. I am unable to do a proper implementation where I could send it as an attachment without saving it on disk temporarily. Here is the code for email as an attachment.
file_name = "temp_file_location.xlsx"
book = xlwt.Workbook()
sheet = book.add_sheet("XYZ")
book.save(file_name)
message = EmailMessage(subject="Subject", body="body",
from_email="random@gmail.com",
to=email_list)
message.attach_file(file_name)
message.send()
There is a similar question here: How to send an email with attachment?
But no solution, and I am unable to send email without saving it on disk temporarily.
Any Ideas?