A boatload of Bugs (#3704)
Co-authored-by: Amelia <77553571+Fesaa@users.noreply.github.com>
This commit is contained in:
parent
ea9b7ad0d1
commit
37734554ba
102 changed files with 2051 additions and 1115 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue