Skip to content

Notifications Provider for SparkPost email delivery service using .Net standard 2.0

License

Notifications You must be signed in to change notification settings

spherus/notifications.mail.sparkpost

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Spherus.Notifications.Mail.SparkPost

Notifications Provider for SparkPost email delivery service

NuGet

Link to the NuGet package

Package Manager: PM> Install-Package Spherus.Notifications.Mail.SparkPost -Version 1.0.1
.NET CLI: > dotnet add package Spherus.Notifications.Mail.SparkPost --version 1.0.1

How to use:

var model = new MailNotificationModel
{
    From = new Address
    {
        Email = "from@yourmail",
        Name = "Your Name"
    },
    Subject = "The subject of email here",
    To = new List<Address>
    {
         new Address
         {
             Email = "to@yourmail",
             Name = "Recipient Name",
             DestinationType = DestinationType.To //This is default, is not mandatory
         },
         new Address
         {
              Email = "cc_email@yourmail",
              Name = "CC Name",
              DestinationType = DestinationType.CC
         },
         new Address
         {
             Email = "bcc_email@yourmail",
             Name = "BCC Name",
             DestinationType = DestinationType.BCC
         }
    },
    Text = "<b>Hello</b> from SparkPost. This is <i>a message</i><img src='cid:ImageName' />",
    ReplyTo = new Address 
    { 
         Email = "reply@yourmail", 
         Name = "Reply Name" 
    }
};

//If attachments are needed
model.Attachments = new List<Attachment>
{
    new Attachment
    {
        Data = File.ReadAllBytes("Path to a pdf file"),
        Name = "PDF",
        Type = "application/pdf"
    }
};

//If inline images are needed
model.Images = new List<Attachment>
{
    new Attachment
    {
        Data = File.ReadAllBytes("Path to inline image"),
        Name = "ImageName", // Note that it should be unique, it's using in text as <img src='cid:ImageName' />
        Type = "image/png"
    }
};

model.Credentials.Add("ApiKey", "Your SparkPost API Key");
model.Credentials.Add("URI", new Uri("https://api.sparkpost.com/api/v1/transmissions"));

var result = await new NotificationProvider()
    .UseSparkPostEmailProvider(model)
    .NotificationService.NotifyAsync();

About

Notifications Provider for SparkPost email delivery service using .Net standard 2.0

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages