A dotnet client library for using Email module in KMD Logic platform through API.
To allow products using Logic platform to send emails
Logic email client provides below options:
- Upload Attachments
- Upload Templates
- Send Emails
- Send simple text emails
- Send email with attachments
- Send email using (HTML) templates
- Send scheduled emails
- Get Email Request Details
To use this library in an ASP.NET Core application, add a reference to the Kmd.Logic.Email.Client nuget package, and add a reference to the Kmd.Logic.Identity.Authorization nuget package.
In projects or components where you need to send Email, add a NuGet package reference to Kmd.Logic.Email.Client.
The LogicTokenProviderFactory authorizes access to the Logic platform through the use of a Logic Identity issued client credential. The authorization token is reused until it expires. You would generally create a single instance of LogicTokenProviderFactory.
The EmailClient accesses the Email service.
To get started:
- Create a subscription in Logic Console. This will provide you with the
SubscriptionId. - Request a client credential. Once issued you can view the
ClientId,ClientSecretandAuthorizationScopein Logic Console. - Create an Email configuration. This will give you the
ConfigurationId. - As soon as the configuration is approved by the Logic Admin, you can start sending emails using it.
Note: Please raise an issue for configuration approval.
The simplest example to send a Email is:
using var httpClient = new HttpClient();
using var tokenProviderFactory = new LogicTokenProviderFactory(configuration.TokenProvider);
var emailClient = new EmailClient(httpClient, tokenProviderFactory, configuration.EmailOptions);
var emailResponse = await emailClient.SendEmail(new SendEmailRequestDetails()).ConfigureAwait(false);Perhaps the easiest way to configure the Email client is from Application Settings.
{
"TokenProvider": {
"ClientId": "",
"ClientSecret": "",
"AuthorizationScope": ""
},
"EmailOptions": {
"SubscriptionId": ""
}
}Below sample console applications are included as references to show how Logic Email service can be used. You will need to provide the settings described above in appsettings.json.
