Posted on 23/09/2019 15:15:15
I've tried to get this working and this is the conclusion.
In order to get it working on 9.3.x, you'd have to update Dynamicweb.Mailing, Dynamicweb.Data and Dynamicweb.Logging. Then you'd have to change the database schema to match the event logging of 9.6.
So, I guess there are four options where three of them are viable:
- Upgrade to at least 9.6 (preferably 9.7) and get the GDPR features out of the box
- Leave the solution at 9.3.4 and be okay with the way it handles email logging
- Create a piece of custom code that injects itself in the mailing process and makes sure that logging is disabled
- Try and get a customized 9.3.4 to work
At this point, I consider option 4 to be the non-viable option.
Option 1 is the most desirable solution, followed by option 2. Option 3 can work but it will disable the logging completely unless you turn on "Save to disk".
The subscriber for option 3 could look something like this:
using Dynamicweb.Extensibility.Notifications;
using Dynamicweb.Mailing;
using System;
using System.Net.Mail;
namespace EmailProxy
{
[Subscribe(Dynamicweb.Mailing.Notifications.EmailNotifications.OnBeforeEmailSend)]
public class EmailProxySubscriber : NotificationSubscriber
{
[ThreadStatic]
private static MailMessage _message;
public override void OnNotify(string notification, NotificationArgs args)
{
var emailArgs = args as Dynamicweb.Mailing.Notifications.EmailSendNotificationArgs;
// Check if the current email is the same as the one we're sending below - if so, return
if (emailArgs.Message == _message)
return;
try
{
_message = emailArgs.Message;
var wasSent = EmailHandler.Send(emailArgs.Message, logging: false, throwException: true);
emailArgs.IsHandled = true;
emailArgs.WasSent = wasSent;
}
catch
{
// TODO: Do something maybe
}
}
}
}
NB: This has only been tested with a single recipient, so you should do your own tests on larger batches.
- Jeppe