Duplicated email message on NOP 4.2

3 months ago
Hi everybody,
we are using a very slow SMTP server and when the messages queue has many messages to sent, seems the the SendEmail Task runs in multiple instances and send the same email many times.
If we increase the interval to 30 minutes the problem is solved. But of course this is not a solution.

Can you tell me if there is any setting, even in versione 4.2, to avoid this overlapping of tasks?
Don't know if helps, but message template are marked as "send immediatly".

Thank you,
3 months ago
Looking at IsTaskAlreadyRunning method (on Task class) we see that there is not any check to be sure that task is not running. It only check if the Interval is elasped.

if (lastStartUtc.AddSeconds(scheduleTask.Seconds) <= DateTime.UtcNow)
      return false;

Thi is my case: task has not completed yet due to a very slow SMTP and for this reason a new instance of SendMail Task is executed.

Hope this helps,

protected virtual bool IsTaskAlreadyRunning(ScheduleTask scheduleTask)
            //task run for the first time
            if (!scheduleTask.LastStartUtc.HasValue && !scheduleTask.LastEndUtc.HasValue)
                return false;
            var lastStartUtc = scheduleTask.LastStartUtc ?? DateTime.UtcNow;

            //task already finished
            if (scheduleTask.LastEndUtc.HasValue && lastStartUtc < scheduleTask.LastEndUtc)
                return false;

            //task wasn't finished last time
            if (lastStartUtc.AddSeconds(scheduleTask.Seconds) <= DateTime.UtcNow)
                return false;

            return true;