private static void SendMessageEmail() { var emailBody = EMailTemplateManager.GetSubscriptionEmailBody(); EMailManager emailer = new EMailManager(); emailer.MailTo = "*****@*****.**"; emailer.Subject = "Test Email"; emailer.MailBody = emailBody; emailer.SendMail(); }
private void emailTimer_Tick(object sender, ElapsedEventArgs e) { try { int totalEmailsProcessed = 0; int emailsDeliveredSuccessfully = 0; int emailsFailedToDeliver = 0; IMessageManager <EmailMessage, EMailQueueItem> emailmanager = new EMailManager(); List <EMailQueueItem> emailqueueItems = emailmanager.GetPendingMessages().ToList(); foreach (var item in emailqueueItems) { MessageDeliveryStatus status = emailmanager.SendMessage(item); totalEmailsProcessed++; if (status == MessageDeliveryStatus.Delivered) { emailsDeliveredSuccessfully++; } else { emailsFailedToDeliver++; } } LogWriter.WriteLine(this.ServiceName, string.Format("Email Delivery Service Called: {0} emailes out of {1} sent successfully while {2} emails could not be sent at moment", emailsDeliveredSuccessfully, totalEmailsProcessed, emailsFailedToDeliver)); } catch (Exception ex) { LogWriter.WriteLine(this.ServiceName, ex.ToString()); } }