Coder Social home page Coder Social logo

spherus / notifications.mail.sparkpost Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 24 KB

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

License: MIT License

C# 100.00%
sparkpost sparkpost-api provider csharp spherus

notifications.mail.sparkpost's Introduction

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();

notifications.mail.sparkpost's People

Contributors

rostislavrotaru avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.