Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EmailBuilder improvements #132

Merged
merged 1 commit into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ Previous classification is not required if changes are simple or all belong to t
## [8.1.8]

### Breaking Changes

- `DocumentConnectorProviderBase` no longer automatically registers document connectors. Instead, it will register available connectors in the dependency container.
This means that document connectors must be registered manually in the dependency container. For this purpose, new extension methods have been added to `IServiceCollection` that allow to register document connectors in the dependency container.
Also the `AddDefaultDocumentConnectors` method has been added in `IServiceCollectionExtensions` to register document connectors that were registered by default before.

### Major Changes

- Added the `IEnmarchaDocumentConnector` interface that extends the existing `IDocumentConnector`. This interface, by now, adds a `CompatibleFileFormats` property that returns the file formats supported by the connector. Existing document connectors have been updated to implement this interface.
- Added `CsvTsvDocumentConnector` document connector that allows to read CSV and TSV files keeping the headers in different chunks.
- Added `SkVisionImageDocumentConnector` which allows to read images and extract text from them. Using Semantic Kernel vision capabilities.
Expand All @@ -42,6 +44,10 @@ Previous classification is not required if changes are simple or all belong to t
- Moved `TableStorageResponseProvider` class to `Encamina.Enmarcha.Conversation`.
- Updated `LocalizedResponseGreetingsProvider.cs` to use new abstractions.

### Minor Changes

- Added `SetRecipients` method to `IEmailBuilder` interface.

## [8.1.7]

### Major Changes
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<PropertyGroup>
<VersionPrefix>8.1.8</VersionPrefix>
<VersionSuffix>preview-02</VersionSuffix>
<VersionSuffix>preview-03</VersionSuffix>
</PropertyGroup>

<!--
Expand Down
12 changes: 12 additions & 0 deletions src/Encamina.Enmarcha.Email.Abstractions/IEmailBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,18 @@ public interface IEmailBuilder
/// <returns>The <see cref="IEmailBuilder"/> so that additional calls can be chained.</returns>
IEmailBuilder SetBody(StringBuilder body, bool isHtml = false);

/// <summary>
/// Sets the e-mail addresses for the recipients of an e-mail, typically for the 'TO', 'CC', or 'BCC' fields, replacing any previously set recipients.
/// </summary>
/// <param name="recipients">
/// A collection of tuples where each tuple contains:
/// - <c>EmailAddress</c>: The recipient's e-mail address.
/// - <c>RecipientName</c>: The recipient's name./>.
/// - <c>RecipientType</c>: The type of recipient (like 'to', 'cc', or 'bcc')./>.
/// </param>
/// <returns>The <see cref="IEmailBuilder"/> so that additional calls can be chained.</returns>
IEmailBuilder SetRecipients(IEnumerable<(string EmailAddress, string? RecipientName, EmailRecipientType RecipientType)> recipients);

/// <summary>
/// Sends the e-mail, thus effectively ending its building.
/// </summary>
Expand Down
13 changes: 13 additions & 0 deletions src/Encamina.Enmarcha.Email.MailKit/EmailService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,19 @@ public IEmailBuilder SetSender(string emailAddress, string? senderName)
/// <inheritdoc/>
public IEmailBuilder SetDefaultSender(string? senderName = null) => SetSender(SmtpClientOptions.User, senderName);

/// <inheritdoc/>
public IEmailBuilder SetRecipients(IEnumerable<(string EmailAddress, string? RecipientName, EmailRecipientType RecipientType)> recipients)
{
Specification.To.Clear();

foreach (var (emailAddress, recipientName, recipientType) in recipients)
{
AddRecipient(emailAddress, recipientName, recipientType);
}

return this;
}

/// <inheritdoc/>
/// <remarks>This implementation does not allows the subject to be <see langword="null"/>.</remarks>
public IEmailBuilder SetSubject(string subject)
Expand Down
Loading