public static void SendMailsInTheQueue()
 {
     int i = 0;
     using (var db = new MatchingDB())
     {
         foreach (var m in GetMessages(db))
         {
             EmailService emailService = new EmailService(m.To, m.Subject, m.Body);
             String status = emailService.SendMessage();
             LogMessage(db, m, status);
             if (status == EmailStatus.Success.ToString())
                 db.EmailQueueMessages.Remove(m);
             i++;
         }
         try
         {
             db.SaveChanges();
         }
         catch (Exception ex)
         {
             log.Info("An error has happened while trying to persist the log info after e-mail has been sent and emaillog has been generated but before queue message has been deleted. Exception is:",ex);
         }
     }
     if(i>0)
         log.Info("The number of emails successfully sent: "+i.ToString()+" at "+DateTime.Now.ToString());
 }
 public void SendMessageTest()
 {
     string to = "*****@*****.**";
     string subject = "Just testing!";
     string body = "An Html <b>test</b> message body.";
     EmailService target = new EmailService(to, subject, body);
     target.SendMessage();
 }