/// <summary> /// Initializes a new instance of the <see cref="NotificationManager"/> class. /// </summary> private NotificationManager() { Console.WriteLine("Notification Service Started."); if (string.IsNullOrEmpty(Program.Configuration["Sendpulse_User_Id"]) || string.IsNullOrEmpty(Program.Configuration["Sendpulse_Secret"])) { Console.WriteLine("Email information not found, will be disabled!"); _sendpulseClient = null; } else { // create our email client _sendpulseClient = new SendPulse.Sendpulse( Program.Configuration["Sendpulse_User_Id"], Program.Configuration["Sendpulse_Secret"]); } }
/// <summary> /// SMTP send mail From: /// https://github.com/sendpulse/sendpulse-rest-api-csharp/blob/master/Sendpulse-rest-api/Examples.cs. /// </summary> /// <param name="sp"> The sp.</param> /// <param name="from_name"> Name of from.</param> /// <param name="from_email"> from email.</param> /// <param name="name_to"> The name to.</param> /// <param name="email_to"> The email to.</param> /// <param name="html"> The HTML.</param> /// <param name="text"> The text.</param> /// <param name="subject"> The subject.</param> /// <param name="attachments">The attachments.</param> internal static void smtpSendMail( SendPulse.Sendpulse sp, string from_name, string from_email, string name_to, string email_to, string html, string text, string subject, Dictionary <string, string> attachments) { Dictionary <string, object> from = new Dictionary <string, object>(); from.Add("name", from_name); from.Add("email", from_email); ArrayList to = new ArrayList(); Dictionary <string, object> elementto = new Dictionary <string, object>(); elementto.Add("name", name_to); elementto.Add("email", email_to); to.Add(elementto); Dictionary <string, object> emaildata = new Dictionary <string, object>(); emaildata.Add("html", html); emaildata.Add("text", text); emaildata.Add("subject", subject); emaildata.Add("from", from); emaildata.Add("to", to); if (attachments.Count > 0) { emaildata.Add("attachments_binary", attachments); } Dictionary <string, object> result = sp.smtpSendMail(emaildata); Console.WriteLine($"Response Status {result["http_code"]}"); Console.WriteLine($"Result {result["data"]}"); Console.ReadKey(); }