private void SendCampaign(Job job, MessageItem messageItem, IEnumerable <Contact> contactsForThisEmail) { job.Status = "Adjusting email stats..."; _adjustEmailStatisticsService.AdjustEmailStatistics(_ecmDataProvider, _recipientManagerFactory.GetRecipientManager(messageItem), job, messageItem, _campaign); PublishEmail(messageItem); var listOfContacts = contactsForThisEmail.ToList(); var contactIndex = 1; foreach (var contact in listOfContacts) { if (job.JobStatus == JobStatus.Cancelling) { return; } job.Status = $"Sending email to contact {contactIndex++} of {listOfContacts.Count}"; try { SendEmailToContact(job, contact, messageItem); } catch (Exception ex) { job.Status = ex.ToString(); Log.Error("Failed", ex, this); } } GenerateEvents(job, messageItem, _campaign.Events, listOfContacts); }
private void SendCampaign(Job job, MessageItem messageItem, List <ContactData> contactsForThisEmail) { job.Status = "Adjusting email stats..."; _adjustEmailStatisticsService.AdjustEmailStatistics(job, messageItem, _campaign); PublishEmail(messageItem); var contactIndex = 1; foreach (var contact in contactsForThisEmail) { if (job.JobStatus == JobStatus.Cancelling) { return; } job.Status = $"Sending email to contact {contactIndex++} of {contactsForThisEmail.Count}"; try { SendEmailToContact(job, contact, messageItem); } catch (Exception ex) { job.Status = ex.ToString(); Log.Error("Failed", ex, this); } } GenerateEvents(job, messageItem, _campaign.Events, contactsForThisEmail); }