Example #1
0
        private void sendMail(String email)
        {
            try
            {
                MailMessage mail = new MailMessage();

                mail.From = new MailAddress("*****@*****.**");
                mail.To.Add(email);
                mail.Subject = "Authentication code ";
                Random random = new Random();

                String code = random.Next().ToString();
                while (code.Length != 10)
                {
                    code = random.Next().ToString();
                }
                code = code + "12";
                Barcode barcode      = new Barcode();
                Color   foreColor    = Color.Black;
                Color   backColor    = Color.Transparent;
                Image   imageBarCode = barcode.Encode(TYPE.UPCA, code, foreColor, backColor);

                mail.Body = "Your code is: " + code;
                var stream = ToStream(imageBarCode, ImageFormat.Png);

                mail.Attachments.Add(new Attachment(stream, "imageBarCode.png", "imageBarCode/png"));



                SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
                SmtpServer.Port        = 587;
                SmtpServer.Credentials = new System.Net.NetworkCredential("*****@*****.**", "12parola34");
                SmtpServer.EnableSsl   = true;
                SmtpServer.Send(mail);
                PopupNotifier popup = new PopupNotifier();
                // popup.Image = Properties.Resources.info;
                popup.TitleText   = "Mail";
                popup.ContentText = "Verify you email";
                popup.Popup();
                _email.UpdateEmail(email, code);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        public IActionResult Post(String email, String code)
        {
            emailParticipant.UpdateEmail(email, code);

            return(Ok(emailParticipant));
        }