usender / unione

UniOne is an open source framework for automated transactional email system. UniOne allows you to work with API from any .NET application

Home Page:https://docs.unione.io/en/web-api-ref?csharp#web-api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NuGet License

UniOne is an open source framework for automated transactional email system. Unione allows you to work with API from any .NET application. Updated to version 1.56 changelog

Official page

https://docs.unione.io

Documentation

Official UniOne Documentation

How to get UniOne

Install-Package Sender.UniOne.ApiClient

or by visiting: https://www.nuget.org/packages/Sender.UniOne.ApiClient/

How to use

Send email in the basic version

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Sender.UniOne.ApiClient;
using Sender.UniOne.ApiClient.Common;
using Sender.UniOne.ApiClient.Email;

namespace Sender.UniOne.Test
{
    class Program
    {
        static async Task Main(string[] args)
        {
            var settings = new UniOneSettings
            {
                ApiKey = "Your API key here",
                Endpoint = "Chose by region", // https://eu1.unione.io or https://us1.unione.io
                IsNeedValidatingRequestBeforeSending = false
            };

            var uniOneClient = new UniOneClient(settings);

            var emailMessage = new EmailMessage
            {
                Subject = "uni one client",
                FromName = "user company",
                FromEmail = "your from email",
                Recipients = new List<Recipient> { new Recipient("remote@email.com") },
                Body = new MessageBody("Example message for ...")
            };

            var response = await uniOneClient.EmailSendAsync(emailMessage);

            Console.WriteLine(response.IsSuccess ? response.JobId : response.Failure.Message);

            Console.ReadKey();
        }
    }
}

Use email substitution

Method 1 (use inheritance class)

public class Example
{
    public void Do()
    {
        var emailMessage = new EmailMessage();
        emailMessage.Recipients.Add(new Recipient("some@email.com")
        {
            Substitutions = new LocalSubstitution
            {
                ToName = "some name",
                CustomerId = "123"
            }
        });
    }

    public class LocalSubstitution : Substitution
    {
        public string CustomerId { get; set; }
    }
}

Method 2 (use as dictionary)

public class Example
{
    public void Do()
    {
        var emailMessage = new EmailMessage();

        var substitutions = new Substitution();
        substitutions.ToName = "some name";
        substitutions.Add("CustomerId", "123");

        emailMessage.Recipients.Add(new Recipient("some@email.com")
        {
            Substitutions = substitutions
        });
    }
}

About

UniOne is an open source framework for automated transactional email system. UniOne allows you to work with API from any .NET application

https://docs.unione.io/en/web-api-ref?csharp#web-api

License:MIT License


Languages

Language:C# 100.0%