public void TestMandrill() { var m = new Mandrill(_log, _cfg.AutoRespondMandrillApiKey); var vars = new Dictionary <string, string> { { "FNAME", "Stas Dulman" }, }; m.Send(vars, "*****@*****.**", "AutoresponderTest", "Autoresponder Test"); }
private void HandleMessage(MailMessage msg) { //_eventLog.WriteEntry("Handle Message begin", EventLogEntryType.Information); if (IsExcludedMail(msg.From.Email)) { return; //Ignore mails from [email protected] and [email protected] } var dateReceived = msg.DateReceived.ToUniversalTime(); if (dateReceived < DateTime.Today.AddDays(_cfg.AutoRespondCountDays)) { //_eventLog.WriteEntry("Old Unseen mail", EventLogEntryType.Information); return; } if (!IsNotExceededCount(dateReceived, msg.From.Email)) { return; } if (!IsWeekend(dateReceived) && !IsNight(dateReceived)) { return; } _oDb.ExecuteNonQuery(Const.InsertAutoresponderLogSpName, new QueryParameter(Const.EmailSpParam, msg.From.Email), new QueryParameter(Const.NameSpParam, msg.From.DisplayName)); var mandrill = new Mandrill(_log, _cfg.AutoRespondMandrillApiKey); var vars = new Dictionary <string, string> { { "FNAME", msg.From.DisplayName ?? msg.From.AsString }, }; _eventLog.WriteEntry("Autoresponding to " + msg.From.Email, EventLogEntryType.Information); mandrill.Send(vars, msg.From.Email, IsWeekend(dateReceived) ? _cfg.AutoRespondMandrillWeekendTemplate : _cfg.AutoRespondMandrillNightTemplate); }