Developer forum

Forum » CMS - Standard features » C# Email Scheduler sends same email twice

C# Email Scheduler sends same email twice

Jonas Mersholm
Reply
I am using the following code in a cronjob to send newsletter mails at a fixed interval. The cronjob calls an .ashx file. The problem is, that the email is being send twice to every recipient, but only sometimes. Other times it will send just once. The code displayed below are the actual code, it it not wrapped in any kind of loop or other iterative method. Any help would be appreciated.
            var email = new Dynamicweb.Modules.EmailMarketing.Email();

            email.SenderEmail = "noreply@domain.dk";
            email.SenderName = "Domain";
            email.Subject = "Nyt fra domain";
            email.DomainName = "www.domain.dk";

            email.PageId = 241;

            var recipientProvider = email.RecipientProvider as AccessUserRecipientProvider;
            if (recipientProvider != null)
            {
                recipientProvider.SetIds(new List<string> { "u7938", "u7917" });
            }

            email.CreateEmailScheduledTask(DateTime.Now);

 


Replies

 
Nicolai Høeg Pedersen
Reply

Try not setting the schedule to now...

 
Jonas Mersholm
Reply

Same problem with 

  email.CreateEmailScheduledTask(DateTime.Now.AddMinutes(1) )

 

You must be logged in to post in the forum