I am trying to implement email functionality on JavaScript based front end. My task is to open default email client (mostly outlook) with an attachment (file). I used mailto, but it doesn't support attachments. Now instead of getting downloaded file as a blob from server, i am trying to get eml based blob, download it, and I assume it will open successfully in outlook with attachment. I am not very well versed in backend ( c# ), so any help will be appreciated. I have this code which gets me the downloaded file path
var fileDetail = await service.DownloadFile(id);
var bytes = File.Exists(fileDetail.Path);
var stream = new MemoryStream(bytes);
return File(stream, fileDetail.MimeType, fileDetail.DownloadFileName);
FileDetail contains filePath, mimeType, fileName etc. This file can be pdf, tiff or any text file.
My aim is to generate an email file with the attached file above that i get ( no need of recipent,subject etc) . Do proper mime type for email, and send it to front end for download.
In case of a plain text + attachment, make the main part
Content-Type: multipart/mixed, convert the attachment data to base 64add two parts to the MIME message: one
text/plain, anotherapplication/octet-streamwith the base 64 encoded file data (see below).As a test, your can create a test EML message by drafting it in Outlook and sending ti to a Gmail mailbox - you can then look at the raw MIME source of the message in your Gmail mailbox. Or you can convert any message in Outlook to MIME using OutlookSpy (I am its author) - open or select a message, click
IConverterSessionbutton on the OutlookSopy ribbon, clickMAPIToMIMEStm.