コード例 #1
0
 public DebugController(IServiceScopeFactory scopeFactory, IBidsManager bidsManager, IOptions <MailSettings> mailSettings, IOptions <MailSecrets> mailSecrets, BidsUpdateJobs bidsUpdateJobs)
 {
     this.bidsManager  = bidsManager;
     this.ScopeFactory = scopeFactory;
     MailSettings      = mailSettings.Value;
     MailSecrets       = mailSecrets.Value;
 }
コード例 #2
0
        private void SendMail()
        {
            MailSecrets mailSecret = null;

            using (var stream = _assembly.GetManifestResourceStream("FindIpAddress.mail_secrets.json"))
            {
                Json.JsonSerializer    serializer   = new Json.JsonSerializer();
                System.IO.StreamReader streamReader = new System.IO.StreamReader(stream);
                Json.JsonTextReader    reader       = new Json.JsonTextReader(streamReader);
                mailSecret = serializer.Deserialize <MailSecrets>(reader);
            }

            var          fromAddress = new MailAddress(mailSecret.Email, mailSecret.Name);
            var          toAddress   = new MailAddress(mailSecret.Email, mailSecret.Name);
            const string subject     = "Adresse";
            string       body        = CheckIpAddress();

            using (var smtp = new SmtpClient())
            {
                smtp.Host                  = "smtp.gmail.com";
                smtp.Port                  = 587;
                smtp.EnableSsl             = true;
                smtp.DeliveryMethod        = SmtpDeliveryMethod.Network;
                smtp.UseDefaultCredentials = false;
                smtp.Timeout               = 10000;
                smtp.Credentials           = new NetworkCredential(fromAddress.Address, mailSecret.Password);

                using (var message = new MailMessage(fromAddress, toAddress))
                {
                    message.Subject    = subject;
                    message.Body       = body;
                    message.IsBodyHtml = true;
                    try
                    {
                        smtp.Send(message);
                        if (this.currentWindowState == System.Windows.WindowState.Normal)
                        {
                            MessageBox.Show("eMail sent", "", MessageBoxButton.OK, MessageBoxImage.Information);
                        }
                    }
                    catch (Exception ep)
                    {
                        MessageBox.Show("Exception Occured:" + ep.Message, "Send Mail Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
            }
        }
コード例 #3
0
 public BidsUpdateJobs(IServiceScopeFactory scopeFactory, IOptions <MailSettings> mailSettings, IOptions <MailSecrets> mailSecrets)
 {
     MailSettings = mailSettings.Value;
     MailSecrets  = mailSecrets.Value;
     ScopeFactory = scopeFactory;
 }