Exemplo n.º 1
0
        public int SendSystem(string email)
        {
            Random     rnd        = new Random();
            SmtpServer smtpserver = new SmtpServer("smtp.gmail.com")
            {
                Port        = 587,
                ConnectType = SmtpConnectType.ConnectSSLAuto,
                User        = email_login,
                Password    = email_pass
            };
            int      code    = rnd.Next(100000, 999999);
            SmtpMail message = new SmtpMail("TryIt")
            {
                From     = email_login,
                To       = email,
                Subject  = "[Verification Code]",
                Priority = EASendMail.MailPriority.High
            };

            message.ImportHtmlBody(@"D:\Downloads\mail.html", ImportHtmlBodyOptions.NoOptions);
            message.HtmlBody = message.HtmlBody.Replace("Your verefication code:", $"Your verefication code:{code}");

            Task.Run(() =>
            {
                SmtpClient client = new SmtpClient();
                client.Connect(smtpserver);
                client.SendMail(message);
            });
            return(code);
        }