diff --git a/Ombi.Services/Interfaces/IMassEmail.cs b/Ombi.Services/Interfaces/IMassEmail.cs
index f3433c5f0..c7b88cad9 100644
--- a/Ombi.Services/Interfaces/IMassEmail.cs
+++ b/Ombi.Services/Interfaces/IMassEmail.cs
@@ -4,6 +4,7 @@ namespace Ombi.Services.Jobs
{
public interface IMassEmail
{
- void MassEmailAdminTest();
+ void Execute(IJobExecutionContext context);
+ void MassEmailAdminTest(string html);
}
}
\ No newline at end of file
diff --git a/Ombi.Services/Jobs/RecentlyAdded.cs b/Ombi.Services/Jobs/RecentlyAdded.cs
index ece148398..937eac8ab 100644
--- a/Ombi.Services/Jobs/RecentlyAdded.cs
+++ b/Ombi.Services/Jobs/RecentlyAdded.cs
@@ -111,11 +111,14 @@ namespace Ombi.Services.Jobs
var settings = NewsletterSettings.GetSettings();
Start(settings, true);
}
- public void MassEmailAdminTest()
+ public void MassEmailAdminTest(string html)
{
- Log.Debug("Starting Test Newsletter");
+ Log.Debug("Starting Mass Email Test");
var settings = NewsletterSettings.GetSettings();
- Start(settings, true);
+ var plexSettings = PlexSettings.GetSettings();
+ var template = new MassEmailTemplate();
+ var body = template.LoadTemplate(html);
+ Send(settings, body, plexSettings, true);
}
private void Start(NewletterSettings newletterSettings, bool testEmail = false)
diff --git a/Ombi.Services/Jobs/Templates/MassEmailTemplate.cs b/Ombi.Services/Jobs/Templates/MassEmailTemplate.cs
new file mode 100644
index 000000000..ea73c027d
--- /dev/null
+++ b/Ombi.Services/Jobs/Templates/MassEmailTemplate.cs
@@ -0,0 +1,58 @@
+#region Copyright
+// /************************************************************************
+// Copyright (c) 2016 Jamie Rees
+// File: RecentlyAddedTemplate.cs
+// Created By: Jamie Rees
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// ************************************************************************/
+#endregion
+
+using System;
+using System.IO;
+using System.Text;
+using System.Windows.Forms;
+using NLog;
+
+namespace Ombi.Services.Jobs.Templates
+{
+ public class MassEmailTemplate
+ {
+ public string TemplateLocation => Path.Combine(Path.GetDirectoryName(Application.ExecutablePath) ?? string.Empty, "Jobs", "Templates", "MassEmailTemplate.html");
+ private static readonly Logger Log = LogManager.GetCurrentClassLogger();
+
+ private const string RecentlyAddedKey = "{@MASSEMAIL}";
+
+ public string LoadTemplate(string html)
+ {
+ try
+ {
+ var sb = new StringBuilder(File.ReadAllText(TemplateLocation));
+ sb.Replace(RecentlyAddedKey, html);
+ return sb.ToString();
+ }
+ catch (Exception e)
+ {
+ Log.Error(e);
+ return string.Empty;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Ombi.Services/Jobs/Templates/MassEmailTemplate.html b/Ombi.Services/Jobs/Templates/MassEmailTemplate.html
new file mode 100644
index 000000000..4fdd04524
--- /dev/null
+++ b/Ombi.Services/Jobs/Templates/MassEmailTemplate.html
@@ -0,0 +1,181 @@
+
+
+
+
+
+ Ombi
+
+
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+
+
+ {@MASSEMAIL}
+ |
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+ |
+ |
+
+
+
+
\ No newline at end of file
diff --git a/Ombi.Services/Ombi.Services.csproj b/Ombi.Services/Ombi.Services.csproj
index 0e47b3669..a37279f7d 100644
--- a/Ombi.Services/Ombi.Services.csproj
+++ b/Ombi.Services/Ombi.Services.csproj
@@ -108,6 +108,7 @@
+
@@ -181,6 +182,9 @@
+
+ PreserveNewest
+
PreserveNewest
diff --git a/Ombi.UI/Modules/Admin/AdminModule.cs b/Ombi.UI/Modules/Admin/AdminModule.cs
index 005646165..181cc1d1b 100644
--- a/Ombi.UI/Modules/Admin/AdminModule.cs
+++ b/Ombi.UI/Modules/Admin/AdminModule.cs
@@ -124,7 +124,7 @@ namespace Ombi.UI.Modules.Admin
ICacheProvider cache, ISettingsService slackSettings,
ISlackApi slackApi, ISettingsService lp,
ISettingsService scheduler, IJobRecord rec, IAnalytics analytics,
- ISettingsService notifyService, IRecentlyAdded recentlyAdded,
+ ISettingsService notifyService, IRecentlyAdded recentlyAdded, IMassEmail massEmail,
ISettingsService watcherSettings ,
ISettingsService discord,
IDiscordApi discordapi, ISettingsService settings, IRadarrApi radarrApi,
@@ -159,6 +159,7 @@ namespace Ombi.UI.Modules.Admin
Analytics = analytics;
NotifySettings = notifyService;
RecentlyAdded = recentlyAdded;
+ MassEmail = massEmail;
WatcherSettings = watcherSettings;
DiscordSettings = discord;
DiscordApi = discordapi;
@@ -1252,7 +1253,7 @@ namespace Ombi.UI.Modules.Admin
try
{
Log.Debug("Clicked Admin Mass Email Test");
- RecentlyAdded.RecentlyAddedAdminTest();
+ MassEmail.MassEmailAdminTest("Dhruv's Test Email");
return Response.AsJson(new JsonResponseModel { Result = true, Message = "Sent email to administrator" });
}
catch (Exception e)
diff --git a/Ombi.UI/Views/Admin/NewsletterSettings.cshtml b/Ombi.UI/Views/Admin/NewsletterSettings.cshtml
index 0a1e07852..02958cb33 100644
--- a/Ombi.UI/Views/Admin/NewsletterSettings.cshtml
+++ b/Ombi.UI/Views/Admin/NewsletterSettings.cshtml
@@ -66,7 +66,7 @@