private void MarkAsSent(TS_ENVIA_EMAIL email) { using (var connection = new OracleConnection(_connectionString)) { using (var command = new OracleCommand(Queries.AtualizarMensagemSucesso, connection)) { command.Parameters.Add("P_IND_SITUACAO", SituacaoEmail.Enviado); command.Parameters.Add("P_DT_EFETIVO_ENVIO", DateTime.Now); command.Parameters.Add("P_COD_EMAIL_TS", email.COD_EMAIL_TS); connection.Open(); command.ExecuteNonQuery(); } } }
private void SendMail(TS_ENVIA_EMAIL email) { try { var mailMsg = email.ToMailMessage(); if (mailMsg.From == null || mailMsg.From.Address == null) mailMsg.From = new MailAddress(_settings.TS_USUARIO_EMAIL); _smtp.Send(mailMsg); _currentLimit.CurrentQuantity++; MarkAsSent(email); } catch (Exception ex) { MarkAsError(email, ex.Message); EventLog.WriteEntry(ex.Message, EventLogEntryType.Error); } }
private void MarkAsError(TS_ENVIA_EMAIL email, string erro) { using (var connection = new OracleConnection(_connectionString)) { using (var command = new OracleCommand(Queries.AtualizarMensagemErro, connection)) { command.Parameters.Add("P_IND_SITUACAO", SituacaoEmail.Erro); command.Parameters.Add("P_TXT_ERRO", erro); command.Parameters.Add("P_COD_EMAIL_TS", email.COD_EMAIL_TS); connection.Open(); command.ExecuteNonQuery(); } } }