Introduced the `EmailAttachmentContext` class to represent email attachments, with properties for file name, content, content type, inline display behavior, and content ID. Used conditional compilation to support both .NET Framework and .NET versions. Updated the `EmailContext` class to include an `Attachments` property, enabling emails to include attachments as byte arrays or file paths. Enhanced the `LimilabsEmailService` class to handle attachments: - Added the `AddAttachments` method to process inline and regular attachments. - Integrated attachment handling into the email-building process.
55 lines
1.4 KiB
C#
55 lines
1.4 KiB
C#
namespace DigitalData.MessagingService.Abstraction;
|
|
|
|
public record EmailContext
|
|
{
|
|
#if NETFRAMEWORK
|
|
public EmailAccountDto Sender { get; set; } = null!;
|
|
#else
|
|
public required EmailAccountDto Sender { get; init; }
|
|
#endif
|
|
|
|
/// <summary>
|
|
/// Recipient email address
|
|
/// </summary>
|
|
|
|
#if NETFRAMEWORK
|
|
public IEnumerable<string> Recipients { get; set; } = null!;
|
|
#else
|
|
public required IEnumerable<string> Recipients { get; init; }
|
|
#endif
|
|
|
|
/// <summary>
|
|
/// Email subject
|
|
/// </summary>
|
|
|
|
#if NETFRAMEWORK
|
|
public string Subject { get; set; } = null!;
|
|
#else
|
|
public required string Subject { get; init; }
|
|
#endif
|
|
|
|
/// <summary>
|
|
/// Email body (HTML or plain text)
|
|
/// </summary>
|
|
#if NETFRAMEWORK
|
|
public string Body { get; set; } = null!;
|
|
#else
|
|
public required string Body { get; init; }
|
|
#endif
|
|
|
|
/// <summary>
|
|
/// Is HTML email (default: true)
|
|
/// </summary>
|
|
#if NETFRAMEWORK
|
|
public bool IsHtml { get; set; } = true;
|
|
#else
|
|
public bool IsHtml { get; init; } = true;
|
|
#endif
|
|
|
|
/// <summary>
|
|
/// Optional list of attachments to include with the email.
|
|
/// Each entry may carry its content as a byte array (<see cref="EmailAttachmentContext.Content"/>)
|
|
/// or reference a file on disk via <see cref="EmailAttachmentContext.FilePath"/>.
|
|
/// </summary>
|
|
public IEnumerable<EmailAttachmentContext> Attachments { get; set; } = [];
|
|
} |