diff --git a/Ombi.Core/Ombi.Core.csproj b/Ombi.Core/Ombi.Core.csproj
index 9866e6fb0..f6562c2fc 100644
--- a/Ombi.Core/Ombi.Core.csproj
+++ b/Ombi.Core/Ombi.Core.csproj
@@ -124,6 +124,7 @@
+
diff --git a/Ombi.Core/SettingModels/MassEmailSettings.cs b/Ombi.Core/SettingModels/MassEmailSettings.cs
new file mode 100644
index 000000000..0be28a92d
--- /dev/null
+++ b/Ombi.Core/SettingModels/MassEmailSettings.cs
@@ -0,0 +1,35 @@
+#region Copyright
+// /************************************************************************
+// Copyright (c) 2016 Jamie Rees
+// File: EmailNotificationSettings.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
+namespace Ombi.Core.SettingModels
+{
+ public sealed class MassEmailSettings : NotificationSettings
+ {
+ public string Users { get; set; }
+ public string Subject { get; set; }
+ public string Body { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/Ombi.Services/Interfaces/IMassEmail.cs b/Ombi.Services/Interfaces/IMassEmail.cs
new file mode 100644
index 000000000..9751cc870
--- /dev/null
+++ b/Ombi.Services/Interfaces/IMassEmail.cs
@@ -0,0 +1,12 @@
+using Quartz;
+
+namespace Ombi.Services.Jobs
+{
+ public interface IMassEmail
+ {
+ void Execute(IJobExecutionContext context);
+ void MassEmailAdminTest(string html, string subject);
+ void SendMassEmail(string html, string subject);
+
+ }
+}
\ No newline at end of file
diff --git a/Ombi.Services/Interfaces/IRecentlyAdded.cs b/Ombi.Services/Interfaces/IRecentlyAdded.cs
index 09a7220f5..c18ca8e27 100644
--- a/Ombi.Services/Interfaces/IRecentlyAdded.cs
+++ b/Ombi.Services/Interfaces/IRecentlyAdded.cs
@@ -5,7 +5,7 @@ namespace Ombi.Services.Jobs
public interface IRecentlyAdded
{
void Execute(IJobExecutionContext context);
- void Test();
+ void RecentlyAddedAdminTest();
void Start();
}
}
\ No newline at end of file
diff --git a/Ombi.Services/Jobs/RecentlyAdded.cs b/Ombi.Services/Jobs/RecentlyAdded.cs
index 563dd35a5..9ee52f231 100644
--- a/Ombi.Services/Jobs/RecentlyAdded.cs
+++ b/Ombi.Services/Jobs/RecentlyAdded.cs
@@ -48,7 +48,7 @@ using Quartz;
namespace Ombi.Services.Jobs
{
- public class RecentlyAdded : HtmlTemplateGenerator, IJob, IRecentlyAdded
+ public class RecentlyAdded : HtmlTemplateGenerator, IJob, IRecentlyAdded, IMassEmail
{
public RecentlyAdded(IPlexApi api, ISettingsService plexSettings,
ISettingsService email, IJobRecord rec,
@@ -105,12 +105,30 @@ namespace Ombi.Services.Jobs
Start();
}
- public void Test()
+ public void RecentlyAddedAdminTest()
{
- Log.Debug("Starting Test Newsletter");
+ Log.Debug("Starting Recently Added Newsletter Test");
var settings = NewsletterSettings.GetSettings();
Start(settings, true);
}
+ public void MassEmailAdminTest(string html, string subject)
+ {
+ Log.Debug("Starting Mass Email Test");
+ var settings = NewsletterSettings.GetSettings();
+ var plexSettings = PlexSettings.GetSettings();
+ var template = new MassEmailTemplate();
+ var body = template.LoadTemplate(html);
+ Send(settings, body, plexSettings, true, subject);
+ }
+ public void SendMassEmail(string html, string subject)
+ {
+ Log.Debug("Starting Mass Email Test");
+ var settings = NewsletterSettings.GetSettings();
+ var plexSettings = PlexSettings.GetSettings();
+ var template = new MassEmailTemplate();
+ var body = template.LoadTemplate(html);
+ Send(settings, body, plexSettings, false, subject);
+ }
private void Start(NewletterSettings newletterSettings, bool testEmail = false)
{
@@ -439,7 +457,7 @@ namespace Ombi.Services.Jobs
sb.Append("
");
}
- private void Send(NewletterSettings newletterSettings, string html, PlexSettings plexSettings, bool testEmail = false)
+ private void Send(NewletterSettings newletterSettings, string html, PlexSettings plexSettings, bool testEmail = false, string subject = "New Content on Plex!")
{
Log.Debug("Entering Send");
var settings = EmailSettings.GetSettings();
@@ -454,7 +472,7 @@ namespace Ombi.Services.Jobs
var message = new MimeMessage
{
Body = body.ToMessageBody(),
- Subject = "New Content on Plex!",
+ Subject = subject
};
Log.Debug("Created Plain/HTML MIME body");
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..02214c6af
--- /dev/null
+++ b/Ombi.Services/Jobs/Templates/MassEmailTemplate.html
@@ -0,0 +1,181 @@
+
+
+
+
+
+ Ombi
+
+
+
+