pvWay.MailJetClientNuGet.Fw 1.0.1

.NET Framework 4.6.1
Install-Package pvWay.MailJetClientNuGet.Fw -Version 1.0.1
dotnet add package pvWay.MailJetClientNuGet.Fw --version 1.0.1
<PackageReference Include="pvWay.MailJetClientNuGet.Fw" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add pvWay.MailJetClientNuGet.Fw --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: pvWay.MailJetClientNuGet.Fw, 1.0.1"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install pvWay.MailJetClientNuGet.Fw as a Cake Addin
#addin nuget:?package=pvWay.MailJetClientNuGet.Fw&version=1.0.1

// Install pvWay.MailJetClientNuGet.Fw as a Cake Tool
#tool nuget:?package=pvWay.MailJetClientNuGet.Fw&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

MailJet API Client for .Net Framework by pvWay


For using this nuGet you should obviously dispose of a MailJet account.



    public interface IMailJetClient
        /// <summary>
        /// Post a mail using a template via the MailJet REST interface
        /// </summary>
        /// <param name="templateId">The unique id of you MailJet template</param>
        /// <param name="fromEmail">The email of the sender</param>
        /// <param name="fromName">The name of the sender</param>
        /// <param name="toEmail">The email of the addressee</param>
        /// <param name="toName">The name of the addressee</param>
        /// <param name="variables">key value dictionary with your MailJet template variables</param>
        /// <param name="subject"></param>
        /// <returns>IMailJetSendResult or null on failure</returns>
        Task<IMailJetSendResult> SendTemplateAsync(
            int templateId,
            string fromEmail, string fromName,
            string toEmail, string toName,
            IDictionary<string, string> variables = null,
            string subject = null);


From the business layer of your application you start by instanciating the MailJet client

            var mjClient = new MailJetClient(
                apiKey: "******", // replace with your own MailJet ApiKey
                apiSecret:"******", // replace with your own MailJet ApiSecret
                logError: Console.WriteLine); // using Console as Logger

Posting an email using a MailJet template

            IMailJetSendResult res = mjClient.SendTemplateAsync(
                templateId: 12345678,
                fromEmail: "invoicing@pvway.com",
                fromName: "pvWay SRL",
                toEmail: "someOne@someDomain",
                toName: "Mr someOne",
                variables: new Dictionary<string, string>
                    {"invoiceNumber", "202015436"},
                    {"invoiceDate", "2020 Dec 25"},
                    {"product", "Merry Christmas Gift"},
                    {"price", "$ 125.33"}
                // use the default template subject
                subject: null)
            if (res.Success)
                foreach (var resMessage in res.Messages)
                    Console.WriteLine($"status: {resMessage.Status}");
                    foreach (var recipientRes in resMessage.To)
                            $"{recipientRes.Email} - {recipientRes.MessageUuid}");

Happy coding 😃

Product Versions
.NET Framework net461 net462 net463 net47 net471 net472 net48
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 2,034 12/28/2020
1.0.0 238 12/27/2020

fix not using template variables