Exemplo n.º 1
0
        public void SendMailResult(QuizDTO quizDto)
        {
            string server   = "smtp.gmail.com";
            string port     = "587";
            string login    = "******";
            string password = "******";

            MailMessage mail = new MailMessage();

            mail.Subject = "Result";
            mail.From    = new MailAddress(login);
            mail.Body    = quizDto.ToString();
            mail.To.Add(new MailAddress(quizDto.Email));
            mail.BodyEncoding = Encoding.UTF8;
            mail.IsBodyHtml   = true;

            SmtpClient client = new SmtpClient();

            client.Host        = server;
            client.Port        = Convert.ToInt32(port);
            client.EnableSsl   = true;
            client.Credentials = new NetworkCredential(login, password);

            try
            {
                client.Send(mail);
            }
            catch { }
        }