static private bool EnviarEmail(string templateText, MailViewModel viewModel)
        {
            if (String.IsNullOrEmpty(templateText))
                throw new ArgumentException("templateText is null or empty.", "templateText");
            if (viewModel == null)
                throw new ArgumentNullException("email", "email is null.");

            MailMessage message = new MailMessage();
            message.IsBodyHtml = true;
            message.Sender = new MailAddress("*****@*****.**");
            message.From = new MailAddress("*****@*****.**");
            message.To.Add(new MailAddress(viewModel.AvaliacaoSolicitacaoUserEmail));

            message.Subject = string.Format("Lembrete para avaliação da Solicitação Reprográfica {0}/{1}",
                viewModel.AvaliacaoSolicitacaoAno,
                viewModel.AvaliacaoSolicitacaoSeq);

            string templateResult = RazorEngine.Razor.Parse(templateText, viewModel);
            message.Body = templateResult;

            try
            {
                MailClient.Send(message);
                return true;
            }
            catch (SmtpException)
            {
                return false;
            }
        }
 private static MailViewModel MapViewModel(EmailCobrancaAvaliacao email)
 {
     var viewModel = new MailViewModel();
     //viewModel.Email = email.Email;
     //viewModel.Ano = email.Avaliacao.Solicitacao.Ano;
     //viewModel.Seq = email.Avaliacao.Solicitacao.Seq;
     //viewModel.DataLimite = email.Avaliacao.DataLimite;
     //viewModel.FullName = email.Avaliacao.Solicitacao.User.FullName;
     //viewModel.IdAvaliacao = email.Avaliacao.Id;
     //viewModel.IdSolicitacao = email.Avaliacao.Solicitacao.Id;
     viewModel.InjectFrom<FlatLoopValueInjection>(email);
     return viewModel;
 }
 public void EnviarEmailTest()
 {
     string templateText = "Enviando email para @Model.AvaliacaoSolicitacaoUserEmail";
     MailViewModel email = new MailViewModel()
     {
         AvaliacaoSolicitacaoUserEmail = "*****@*****.**",
         AvaliacaoSolicitacaoAno = 2012,
         AvaliacaoSolicitacaoSeq = 1,
         AvaliacaoSolicitacaoId = 1,
         AvaliacaoId = 1,
         AvaliacaoDataLimite = DateTime.Now.AddDays(2),
         AvaliacaoSolicitacaoUserFullName = "Paolo Haji de Carvalho Bueno"
     };
     bool expected = true;
     bool actual = false;
     actual = Program_Accessor.EnviarEmail(templateText, email);
     Assert.AreEqual(expected, actual);
 }