Duplicate Emails

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
8 years ago
We have solved this issue only duplicating the web site.. I tried also with Nop 3.6 but we have same issue: multiple email. No better solution from my side
8 years ago
zrmax wrote:
We have solved this issue only duplicating the web site.. I tried also with Nop 3.6 but we have same issue: multiple email. No better solution from my side

what do you mean by "duplicating the web site" because i'm currently NOT using a multi store setup.
8 years ago
Hi, it's happens in my case only when multistore is enabled. Otherwise I have not problem..
8 years ago
zrmax wrote:
Hi, it's happens in my case only when multistore is enabled. Otherwise I have not problem..

i don't even know, how to "disable" multistore. i having just one store in the list enough?
8 years ago
yes, you have not the multistore .. I think that origin of your problem is different. I have not idea why it happens.. in your and my case but I image it is realted to IIS
7 years ago
I modify part of the code as follows:
archive:  \libraries\nop.services\messages\queuedmessagessendtask.cs
public virtual void Execute()
        {
            var maxTries = 3;
            //tvt 20160630 Busca la cuenta default
                 var emailAccount = _emailAccountService.GetEmailAccountById(_emailAccountSettings.DefaultEmailAccountId);
                if (emailAccount == null)
                    emailAccount = _emailAccountService.GetAllEmailAccounts().FirstOrDefault();
                if (emailAccount == null)
                    throw new Exception("No email account could be loaded");
            var queuedEmails = _queuedEmailService.SearchEmails(null, null, null, null,
                true, maxTries, false, 0, 500);
            foreach (var queuedEmail in queuedEmails)
            {
                if (queuedEmail.EmailAccount == emailAccount)//tvt 20160630 valida que de la lista solo se envien los correos que coinciden con el id de email default de la tienda
                {
                    var bcc = String.IsNullOrWhiteSpace(queuedEmail.Bcc)
                            ? null
                            : queuedEmail.Bcc.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                    var cc = String.IsNullOrWhiteSpace(queuedEmail.CC)
                                ? null
                                : queuedEmail.CC.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

                    try
                    {
                        _emailSender.SendEmail(queuedEmail.EmailAccount,
                            queuedEmail.Subject,
                            queuedEmail.Body,
                           queuedEmail.From,
                           queuedEmail.FromName,
                           queuedEmail.To,
                           queuedEmail.ToName,
                           queuedEmail.ReplyTo,
                           queuedEmail.ReplyToName,
                           bcc,
                           cc,
                           queuedEmail.AttachmentFilePath,
                           queuedEmail.AttachmentFileName,
                           queuedEmail.AttachedDownloadId);

                        queuedEmail.SentOnUtc = DateTime.UtcNow;
                    }
                    catch (Exception exc)
                    {
                        _logger.Error(string.Format("Error sending e-mail. {0}", exc.Message), exc);
                    }
                    finally
                    {
                        queuedEmail.SentTries = queuedEmail.SentTries + 1;
                        _queuedEmailService.UpdateQueuedEmail(queuedEmail);
                    }
                }
            }
}

NOTE: Only send emails templates with the default account.
7 years ago
Yesterday, I disabled the scheduled task that sends email in nopCommerce, restarted the application, and created a scheduled task using the task scheduler in Windows Server 2012(My web server's operating system). The task opens a browser with the following URL: https://www.MYWEBSITE.com/Admin/ScheduleTask/RunNow/1. It seems to be working great (no more duplicate emails!!!) on my multi-store scenario.
Now that my solution/hack is working, I built a plugin to allow anonymous access to the QueuedMessagesSendTask method.

Does anyone see a problem with this solution?
I'll post again if something changes.

PS: I'm using a second scheduled task, as a test, to re-queue 9 emails sent to me, every hour.
So Far ...NO DUPLICATES!
7 years ago
tompetter wrote:
...I built a plugin to allow anonymous access to the QueuedMessagesSendTask method.

Does anyone see a problem with this solution?

I would add at least some security key as parameter (query string) to this URL
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.