private void ProcessEmailMessage(string AppInstance, Message msg) { try { // make sure this is not a dupe using (var db = new DailyLog_dbEntities()) { var rows = db.MessageQueues.Where(q => q.AppInstance == AppInstance && q.ClientKey == msg.Key); //if (rows.Count() == 0) //{ // ServerException.Report(new Exception(string.Format("EmailOut message not found in the q: {0} / {1}", AppInstance, msg.Key))); // return; // try the next time (to make sure no dupe e-mails are sent) //} //if (rows.Where(q => q.Processed != null).Count() > 0) // return; // already processed EmailOutMessage email = (EmailOutMessage)Util.Deserialize(msg.Body, typeof(EmailOutMessage)); EMail.Send(email); rows.First().Processed = DateTime.Now; db.SaveChanges(); } } catch (Exception ex) { ServerException.Report(ex); } }
public static void Send(EmailOutMessage message) { Send(message.To, message.Subject, message.BodyHtml); }