A boatload of Bugs (#3704)

Co-authored-by: Amelia <77553571+Fesaa@users.noreply.github.com>
This commit is contained in:
Joe Milazzo 2025-04-05 15:52:01 -05:00 committed by GitHub
parent ea9b7ad0d1
commit 37734554ba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
102 changed files with 2051 additions and 1115 deletions

View file

@ -17,6 +17,7 @@ using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using MimeKit;
using MimeTypes;
namespace API.Services;
#nullable enable
@ -355,9 +356,21 @@ public class EmailService : IEmailService
if (userEmailOptions.Attachments != null)
{
foreach (var attachment in userEmailOptions.Attachments)
foreach (var attachmentPath in userEmailOptions.Attachments)
{
await body.Attachments.AddAsync(attachment);
var mimeType = MimeTypeMap.GetMimeType(attachmentPath) ?? "application/octet-stream";
var mediaType = mimeType.Split('/')[0];
var mediaSubtype = mimeType.Split('/')[1];
var attachment = new MimePart(mediaType, mediaSubtype)
{
Content = new MimeContent(File.OpenRead(attachmentPath)),
ContentDisposition = new ContentDisposition(ContentDisposition.Attachment),
ContentTransferEncoding = ContentEncoding.Base64,
FileName = Path.GetFileName(attachmentPath)
};
body.Attachments.Add(attachment);
}
}