Exemple #1
0
        public void mailPassword()
        {
            try
            {
                MailMessage mail = new MailMessage();
                SmtpClient  smtp = new SmtpClient("smtp.gmail.com");

                mail.From = new MailAddress("*****@*****.**");
                mail.To.Add(this.Email);
                mail.Subject = "Password Recovery";
                mail.Body    = string.Format(
                    @"Dear {0},
                      Your Password for the La Pieus Aqua Aquaponics Monitoring application is: {1}", this.Username, this.Password);
                smtp.Port        = 587;
                smtp.Credentials = new System.Net.NetworkCredential("additionaladdress.tanya", "LaPieusAqua");
                smtp.EnableSsl   = true;

                smtp.Send(mail);
            }
            catch (Exception)
            {
                DataAccessLayer.FileHandler file = new DataAccessLayer.FileHandler("emailErrors.csv");
                List <string> error = new List <string> {
                    "The password email could not be sent to user: " + this.Username
                };
                file.WriteToTxt(error);
            }
        }
        public void saveNotification()
        {
            DataAccessLayer.FileHandler fh = new DataAccessLayer.FileHandler("notifications.txt");
            List <string> notifications    = new List <string>();

            notifications.Add(this.saveString());
            fh.WriteToTxt(notifications);
        }
        public void mailNotifcation(string email, string tankName, string sensorName, string boundStatus, decimal outOfBoundValue)
        {
            try
            {
                MailMessage mail = new MailMessage();
                SmtpClient  smtp = new SmtpClient("smtp.gmail.com");

                mail.From = new MailAddress("*****@*****.**");
                mail.To.Add(email);
                mail.Subject = "Sensor reading out of bounds";
                if (boundStatus == "Bottom")
                {
                    mail.Body = string.Format(
                        @"IMPORTANT NOTIFICATION!,
                      The {0} sensor found in {1} is currently {2} lower than the critical range", sensorName, tankName, outOfBoundValue);
                }

                if (boundStatus == "Top")
                {
                    mail.Body = string.Format(
                        @"IMPORTANT NOTIFICATION!,
                      The {0} sensor found in {1} is currently {2} higher than the critical range", sensorName, tankName, outOfBoundValue);
                }

                smtp.Port        = 587;
                smtp.Credentials = new System.Net.NetworkCredential("additionaladdress.tanya", "LaPieusAqua");
                smtp.EnableSsl   = true;

                smtp.Send(mail);
            }
            catch (Exception)
            {
                DataAccessLayer.FileHandler file = new DataAccessLayer.FileHandler("emailErrors.csv");
                List <string> error = new List <string> {
                    "The notification email could not be sent to user: " + email
                };
                file.WriteToTxt(error);
            }
        }