/// <summary>
        ///     Send report as an attachment
        /// </summary>
        /// <param name="path">file to attach to email</param>
        /// <param name="verbose">true for verbose positive response</param>
        public void SendAsAttachment(string path, bool verbose = true)
        {
            Cursor.Current = Cursors.WaitCursor;

            try
            {
                var email = new Email();

                email.AddTo("Damage Report", @"*****@*****.**");
                email.From    = @"*****@*****.**";
                email.Subject = Subject;

                if (!string.IsNullOrEmpty(CC))
                {
                    email.AddCC(CC, CC);
                }

                email.AddFileAttachment(path);

                SendMail(email);

                Cursor.Current = Cursors.Default;
                if (verbose)
                {
                    MessageBox.Show("Email Send Successful", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception e)
            {
                Cursor.Current = Cursors.Default;
                var reason = string.Format(@"Failed to send email : {0}", e.Message);
                MessageBox.Show(reason, @"Error", MessageBoxButtons.OK);
            }
        }
        /// <summary>
        ///   Send this email
        /// </summary>
        public void Send(bool verbose = true)
        {
            Cursor.Current = Cursors.WaitCursor;

            try
            {
                var email = new Email();
                if (!string.IsNullOrEmpty(Report))
                {
                    var mht    = new Mht();
                    var emlStr = mht.GetEML(Report);
                    if (mht.LastMethodSuccess != true)
                    {
                        throw new Exception(mht.LastErrorText);
                    }

                    var success = email.SetFromMimeText(emlStr);
                    if (!success)
                    {
                        throw new Exception(email.LastErrorText);
                    }
                }

                email.AddTo("Damage Report", @"*****@*****.**");
                email.From    = @"*****@*****.**";
                email.Subject = Subject;

                if (!string.IsNullOrEmpty(CC))
                {
                    email.AddCC(CC, CC);
                }

                SendMail(email);
                Cursor.Current = Cursors.Default;

                if (verbose)
                {
                    MessageBox.Show("Email Send Successful", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception e)
            {
                Cursor.Current = Cursors.Default;
                var reason = string.Format(@"Failed to send email : {0}", e.Message);
                MessageBox.Show(reason, @"Error", MessageBoxButtons.OK);
            }
        }
Esempio n. 3
0
        public ActionResult SendEOLStatements(string Month)
        {
            string   Errors     = "Statements have been sent!";
            DateTime date       = DateTime.ParseExact(Month, "MMMM", CultureInfo.CurrentCulture);
            DateTime createDate = new DateTime(date.Year, date.Month, 1).AddMonths(1).AddSeconds(-1);

            DateTime billingDate = createDate.AddMonths(-1); // Send statements for 1 month past last lease so customer can check that there are no more billings

            AuleaseEntities db = new AuleaseEntities();

            List <Department>  activeDepts = db.Leases.Where(n => n.EndDate >= billingDate).Select(n => n.Department).Distinct().ToList();
            List <Coordinator> people      = activeDepts.SelectMany(n => n.Coordinators).Distinct().ToList();

            foreach (var person in people)
            {
                // uncomment for production
                //Email email = new Email();
                //email.From("*****@*****.**");
                //email.AddTo(person.GID + "@auburn.edu");
                //email.AddCC("*****@*****.**");
                //email.Subject = "AU Lease End of Lease Statement";
                //email.Body = "<html><body><p>Your " + Month + " end of lease statement(s) is now ready. Please visit <a href=\"cws.auburn.edu/oit/aulease/management\">cws.auburn.edu/oit/aulease/management</a> to view your statement(s) to place future orders.</p><br /><p>Sincerely,</p><p>AU Lease</p></body></html>";
                //email.HTML = true;
                //try
                //{
                //    email.Send();
                //}
                //catch
                //{
                //    Errors += "\n Email failed for:" + person.GID;
                //}
            }

            Email email = new Email();

            email.From("*****@*****.**");
            email.AddTo("*****@*****.**");
            email.AddCC("*****@*****.**");
            email.Subject = "AU Lease End of Lease Statement";
            email.Body    = "<html><body><p>Your " + Month + " end of lease statement(s) is now ready. Please visit <a href=\"cws.auburn.edu/oit/aulease/management\">cws.auburn.edu/oit/aulease/management</a> to view your statement(s) to place future orders.</p><br /><p>Sincerely,</p><p>AU Lease</p></body></html>";
            email.HTML    = true;
            email.Send();

            ViewBag.error = Errors;
            return(View());
        }
        public void sendRepairEmail(string Assignee, Component comp, string RepairNote)
        {
            Email email = new Email();

            email.AddTo(Assignee + "@auburn.edu");
            email.AddCC("*****@*****.**");
            // email.From("*****@*****.**"); //emails from [email protected] if excluded
            email.Subject = "AU Lease Repair Ticket";
            email.HTML    = true;
            email.Body    = "<p>You have a new ticket assigned to you for an AU Lease machine. Please attend to the machine at your earliest convinience" +
                            " and be sure to update any status updates in the database.</p>" +
                            "<p>Serial Number: " + comp.SerialNumber + "</p>" +
                            "<p>Lease Tag: " + comp.LeaseTag + "</p>" +
                            "<p>Component: " + comp.Type.Name + "</p>" +
                            "<p>Notes: " + RepairNote + "</p>";

            email.Send();
        }
Esempio n. 5
0
        public ActionResult SendBillingStatements(string Month)
        {
            string   Errors     = "Statements have been sent!";
            DateTime date       = DateTime.ParseExact(Month, "MMMM", CultureInfo.CurrentCulture);
            DateTime createDate = new DateTime(date.Year, date.Month, 1).AddMonths(1).AddSeconds(-1);

            Statement stat = new Statement {
                Date = createDate
            };
            AuleaseEntities db = new AuleaseEntities();

            db.Statements.Add(stat);
            db.SaveChanges();

            DateTime billingDate = createDate.AddMonths(-1); // Send statements for 1 month past last lease so customer can check that there are no more billings

            List <Department>  activeDepts = db.Leases.Where(n => n.EndDate >= billingDate).Select(n => n.Department).Distinct().ToList();
            List <Coordinator> people      = activeDepts.SelectMany(n => n.Coordinators).Where(n => n.BillingAccess == true).Distinct().ToList();

            foreach (var person in people)
            {
                // uncomment for production
                Email email = new Email();
                email.From("*****@*****.**");
                email.AddTo(person.GID + "@auburn.edu");
                email.AddCC("*****@*****.**");
                email.Subject = "AU Lease Billing Statement";
                email.Body    = "<html><body><p>Your " + Month + " statement(s) is now ready. Please visit <a href=\"https://cws.auburn.edu/oit/aulease/statements\">https://cws.auburn.edu/oit/aulease/statements</a> to view your billing statement(s).</p><br /><p>Sincerely,</p><p>AU Lease</p></body></html>";
                email.HTML    = true;
                try
                {
                    email.Send();
                }
                catch
                {
                    Errors += "\n Email failed for:" + person.GID;
                }
            }

            ViewBag.error = Errors;
            return(View());
        }