示例#1
0
        private void SendEmail()
        {
            Dictionary <int, String> FeedbackOptn  = Utilities.ProblemTypesList;
            Dictionary <int, String> FeedbackValue = Utilities.FeedbackOptionsList;
            Email email = new Email();

            user = GetUserObject();
            if (problem != null)
            {
                hotel           = GetHotelObject();
                email.ToAddress = hotel.Email;
                String name         = user.LastName;
                String room         = user.RoomNo;
                String problemtype  = FeedbackOptn[problem.IncedentType];
                String problemvalue = FeedbackValue[problem.FeedbackValue];
                String checkout     = user.CheckOutDate.ToShortDateString();
                String description  = problem.IncedentDescription;
                String phone        = user.Phone;
                String custemail    = user.Email;
                String footer       = System.Configuration.ConfigurationManager.AppSettings["emailfooter"];
                image         = GetImage("file");
                email.Body    = $"<!doctype html><html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"><title>Reliable WiFi </title><style>a:link {{color: #0a79ea;text-decoration: none;}}a:visited {{color: #000000;text-decoration: none;}}a:link#tops {{color: #000000;text-decoration: none;}}body, td, th {{font-family: Arial, \"Helvetica Neue\", Helvetica, Gotham, sans-serif;font-style: normal;font-weight: normal;font-size: 14px;color: #000000;}}body {{margin-left: 10px;margin-top: 10px;margin-right: 10px;margin-bottom: 10px;background-color: #FFFFFF;}}.BODY {{border-bottom: 1px solid #e8eef2;border-left: 1px solid #e8eef2;border-right: 1px solid #e8eef2;border-top: 1px solid #e8eef2;}}.tableu {{border-bottom: 2px solid #F4CC1F;border-left: 2px solid #F4CC1F;border-right: 2px solid #F4CC1F;border-top: 2px solid #F4CC1F;}}</style></head><body><table bgcolor=\"#ffffff\" cellpadding=\"0\" cellspacing=\"0\" align=\"center\" border=\"0\" class=\"BODY\" width=\"600\"> <tr> <td align=\"center\"><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"> <tr> <td valign=\"top\"><a href=\"http://na414-41ac69.pages.infusionsoft.net/\"><img src=\"http://finalhotelproject20180523071047.azurewebsites.net/images/logohotel.png\" alt=\"Banner\" style=\"display:block\" title=\"Banner\"></a></td> </tr> </table> <table background=\"#FAF9F7\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"600\" bgcolor=\"#FAF9F7\"> <tbody><tr><td bgcolor=\"#FAFAF8\" style=\"padding: 10px 25px 10px 25px; text-align: center; color: #000000; font-size: 24px; background-color: #FAFAF8;\"><b>A problem has been reported</b></td></tr> <tr> <td bgcolor=\"#FAFAF8\" style=\"padding: 10px 25px 10px 25px; text-align: center; color: #000000; font-size: 24px; background-color: #FAFAF8;\"><b>{problemtype}:- {problemvalue}</b></td></tr><tr><td bgcolor=\"#FAFAF8\" style=\"padding: 10px 25px 10px 25px; text-align: center; color: #000000; font-size: 24px; background-color: #FAFAF8;\">Room No:- {room}</td></tr><tr><td bgcolor=\"#FAFAF8\" style=\"padding: 10px 25px 10px 25px; text-align: center; color: #000000; font-size: 24px; background-color: #FAFAF8;\">Customer LastName:- {name}</td></tr><tr><td bgcolor=\"#FAFAF8\" style=\"padding: 10px 25px 10px 25px; text-align: center; color: #000000; font-size: 24px; background-color: #FAFAF8;\">Checkout date:- {checkout}</td></tr><tr><td bgcolor=\"#FAFAF8\" style=\"padding: 10px 25px 10px 25px; text-align: center; color: #000000; font-size: 24px; background-color: #FAFAF8;\">Customer Email:- {custemail}</td></tr><tr><td bgcolor=\"#FAFAF8\" style=\"padding: 10px 25px 10px 25px; text-align: center; color: #000000; font-size: 24px; background-color: #FAFAF8;\">Customer Phone:- <a href='tel://{phone}'>{phone}</a></td></tr><tr><td bgcolor=\"#FAFAF8\" style=\"padding: 10px 25px 10px 25px; text-align: center; color: #000000; font-size: 24px; background-color: #FAFAF8;\">Description:- {description}</td></tr> </tbody> </table> <table background=\"#FAF9F7\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"600\" bgcolor=\"#FAF9F7\"> <tbody> <tr> <td bgcolor=\"#FAFAF8\" style=\"padding: 15px 25px 20px 25px; text-align: center; color: #000000; font-size: 24px; background-color: #FAFAF8;\">From Management.<br /></td> </tr> </tbody> </table> <table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"600\" bgcolor=\"#1F4691\"> <tbody> <tr> <td bgcolor=\"#1F4691\" style=\"padding:10px 10px 10px 10px;text-align:center; line-height:22px; color: #FFFFFF\">{footer}</td> </tr> </tbody> </table></td> </tr></table></body></html>";
                email.Subject = string.Format("{0} - A Problem has been Reported", hotel.Brand);
                Utilities.SendEmail(email, false, image);
            }
        }
        private void SubmitFeedback(bool isQuick = false)
        {
            Feedback feedback = CreateFeedback();

            if (isQuick)
            {
                Feedback.InsertFeedback(feedback);
            }
            else
            {
                HotelDBApp.Image image = GetImage("review_file");
                if (feedback == null)
                {
                    ShowError("Something went wrong. Please try again!");
                }
                else if (Feedback.InsertFeedback(feedback) > 0)
                {
                    Sendemail(image);
                    PnlFieldContainer.Visible  = false;
                    PnlSuccessFailure.Visible  = true;
                    PnlSuccessFailure.CssClass = "notification alert-success spacer-t10";
                    LblStatus.Text             = "Thanks for your feedback!";
                }
                else
                {
                    ShowError("Something went wrong. Please try again!");
                }
            }
        }
        private int GetFeedbackValue(IncedentTypes incedent)
        {
            String feedbackValue = String.Empty;

            if (incedent == IncedentTypes.CommonArea)
            {
                feedbackValue = HdnCommon.Value;
                image         = GetImage("common_file");
            }

            else if (incedent == IncedentTypes.FrontDesk)
            {
                feedbackValue = HdnFrontdesk.Value;
                image         = GetImage("frontdesk_file");
            }

            else if (incedent == IncedentTypes.Housekeeping)
            {
                feedbackValue = HdnHousekeeping.Value;
                image         = GetImage("housekeeping_file");
            }

            else if (incedent == IncedentTypes.Maintenance)
            {
                feedbackValue = HdnMaintenance.Value;
                image         = GetImage("maintain_file");
            }

            else if (incedent == IncedentTypes.Room)
            {
                feedbackValue = HdnRoom.Value;
                image         = GetImage("room_file");
            }

            else if (incedent == IncedentTypes.WiFiInternet)
            {
                feedbackValue = HdnWifi.Value;
                image         = GetImage("internet_file");
            }
            else if (incedent == IncedentTypes.Food)
            {
                feedbackValue = HdnFood.Value;
                image         = GetImage("food_file");
            }
            else if (incedent == IncedentTypes.Fitness)
            {
                feedbackValue = HdnFitness.Value;
                image         = GetImage("fitness_file");
            }
            else if (incedent == IncedentTypes.Parking)
            {
                feedbackValue = HdnParking.Value;
                image         = GetImage("parking_file");
            }

            return(Convert.ToInt32(feedbackValue));
        }
示例#4
0
        static void Execute(Email email, bool isRating, HotelDBApp.Image image)
        {
            /*var apiKey = System.Configuration.ConfigurationManager.AppSettings["apiKey"];
             * var client = new SendGridClient(apiKey);
             * var from = new EmailAddress("*****@*****.**", "Example User");
             * var subject = "A Problem has been Reported";
             * var to = new EmailAddress(email.ToAddress.Trim(), "Example User");
             * var plainTextContent = email.Comments;
             * var htmlContent = !isRating? String.Format("<strong>{0}---{1}</strong><p>Room No. {2}</p><p>Cust Last Name {3}</p><p>Checkout Date {4}</p><p>Description: {5}</p>", email.ProblemType,email.ProblemValue,email.RoomNo,email.CustName,email.CheckoutDate,email.Comments): String.Format("<strong>--A {0} Star Feedback Has been Reported</strong><p>Name: {1}</p><p>Customer Email: {2}</p><p>Checkout Date {3}</p><p>Description: {4}</p>", email.ProblemValue,email.CustName, email.UserEmail, email.CheckoutDate, email.Comments);
             * var msg = MailHelper.CreateSingleEmail(from, to, subject, plainTextContent, htmlContent);
             * var response = client.SendEmailAsync(msg);*/
            String from     = System.Configuration.ConfigurationManager.AppSettings["emailId"];
            String password = System.Configuration.ConfigurationManager.AppSettings["password"];

            try
            {
                using (System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage())
                {
                    mail.From = new System.Net.Mail.MailAddress(from);

                    // The important part -- configuring the SMTP client
                    SmtpClient smtp = new SmtpClient();
                    smtp.Port                  = 587;                                                              // [1] You can try with 465 also, I always used 587 and got success
                    smtp.EnableSsl             = true;
                    smtp.DeliveryMethod        = SmtpDeliveryMethod.Network;                                       // [2] Added this
                    smtp.UseDefaultCredentials = false;                                                            // [3] Changed this
                    smtp.Credentials           = new System.Net.NetworkCredential(mail.From.ToString(), password); // [4] Added this. Note, first parameter is NOT string.
                    smtp.Host                  = "smtp-mail.outlook.com";

                    //recipient address
                    mail.To.Add(new MailAddress(email.ToAddress));

                    //Formatted mail body
                    mail.IsBodyHtml = true;
                    mail.Subject    = String.IsNullOrEmpty(email.Subject) ? "A Problem has been Reported": email.Subject;
                    //String link = String.Format("FeedbackForm.aspx?hotelid={0}", item["HotelID"].ToString());
                    string st = !isRating?String.Format("<strong>{0}---{1}</strong><p>Room No. {2}</p><p>Cust Last Name {3}</p><p>Checkout Date {4}</p><p>Cust Email {5}</p><p>Cust Phone {6}</p><p>Description: {7}</p>", email.ProblemType, email.ProblemValue, email.RoomNo, email.CustName, email.CheckoutDate, email.UserEmail, email.Phone, email.Comments) : String.Format("<strong>--A {0} Star Feedback Has been Reported</strong><p>Name: {1}</p><p>Customer Email: {2}</p><p>Customer Phone: {6}</p><p>Checkout Date {3}</p><p>Problem Type: {4}</p><p>Description: {5}</p>", email.ProblemValue, email.CustName, email.UserEmail, email.CheckoutDate, email.ProblemText, email.Comments, email.Phone);

                    if (image != null)
                    {
                        System.Net.Mail.Attachment attachment;
                        attachment = new System.Net.Mail.Attachment(image.UploadedImage, image.Name);
                        mail.Attachments.Add(attachment);
                    }

                    mail.Body = String.IsNullOrEmpty(email.Body)? st : email.Body;
                    smtp.Send(mail);
                }
            }
            catch (Exception x)
            {
                Debug.WriteLine(x);
            }
        }
        private HotelDBApp.Image GetImage(String name)
        {
            System.IO.Stream upload = null;
            if ((upload = Request.Files[name].InputStream) != null && Request.Files[name].ContentLength > 0)
            {
                image = new HotelDBApp.Image()
                {
                    UploadedImage = upload, Name = Request.Files[name].FileName
                };
            }

            return(image);
        }
        private void Sendemail(HotelDBApp.Image image)
        {
            String name        = user.LastName;
            String room        = user.RoomNo;
            String star        = HdnRating.Value;
            String anyproblem  = HdnProblemTypeText.Value;
            String checkout    = user.CheckOutDate.ToShortDateString();
            String description = TxtComments.Text;
            String phone       = user.Phone;
            String custemail   = user.Email;
            String footer      = System.Configuration.ConfigurationManager.AppSettings["emailfooter"];
            String body        = $"<!doctype html><html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"><title>Reliable WiFi </title><style>a:link {{color: #0a79ea;text-decoration: none;}}a:visited {{color: #000000;text-decoration: none;}}a:link#tops {{color: #000000;text-decoration: none;}}body, td, th {{font-family: Arial, \"Helvetica Neue\", Helvetica, Gotham, sans-serif;font-style: normal;font-weight: normal;font-size: 14px;color: #000000;}}body {{margin-left: 10px;margin-top: 10px;margin-right: 10px;margin-bottom: 10px;background-color: #FFFFFF;}}.BODY {{border-bottom: 1px solid #e8eef2;border-left: 1px solid #e8eef2;border-right: 1px solid #e8eef2;border-top: 1px solid #e8eef2;}}.tableu {{border-bottom: 2px solid #F4CC1F;border-left: 2px solid #F4CC1F;border-right: 2px solid #F4CC1F;border-top: 2px solid #F4CC1F;}}</style></head><body><table bgcolor=\"#ffffff\" cellpadding=\"0\" cellspacing=\"0\" align=\"center\" border=\"0\" class=\"BODY\" width=\"600\"> <tr> <td align=\"center\"><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"> <tr> <td valign=\"top\"><a href=\"http://na414-41ac69.pages.infusionsoft.net/\"><img src=\"http://finalhotelproject20180523071047.azurewebsites.net/images/logohotel.png\" alt=\"Banner\" style=\"display:block\" title=\"Banner\"></a></td> </tr> </table> <table background=\"#FAF9F7\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"600\" bgcolor=\"#FAF9F7\"> <tbody><tr><td bgcolor=\"#FAFAF8\" style=\"padding: 10px 25px 10px 25px; text-align: center; color: #000000; font-size: 24px; background-color: #FAFAF8;\"><b>A {star} Star Review Has Been Submitted</b></td></tr><tr><td bgcolor=\"#FAFAF8\" style=\"padding: 10px 25px 10px 25px; text-align: center; color: #000000; font-size: 24px; background-color: #FAFAF8;\">Problem Type:- {anyproblem}</td></tr><tr><td bgcolor=\"#FAFAF8\" style=\"padding: 10px 25px 10px 25px; text-align: center; color: #000000; font-size: 24px; background-color: #FAFAF8;\">Customer LastName:- {name}</td></tr><tr><td bgcolor=\"#FAFAF8\" style=\"padding: 10px 25px 10px 25px; text-align: center; color: #000000; font-size: 24px; background-color: #FAFAF8;\">Checkout date:- {checkout}</td></tr><tr><td bgcolor=\"#FAFAF8\" style=\"padding: 10px 25px 10px 25px; text-align: center; color: #000000; font-size: 24px; background-color: #FAFAF8;\">Customer Email:- {custemail}</td></tr><tr><td bgcolor=\"#FAFAF8\" style=\"padding: 10px 25px 10px 25px; text-align: center; color: #000000; font-size: 24px; background-color: #FAFAF8;\">Customer Phone:- {phone}</td></tr><tr><td bgcolor=\"#FAFAF8\" style=\"padding: 10px 25px 10px 25px; text-align: center; color: #000000; font-size: 24px; background-color: #FAFAF8;\">Description:- {description}</td></tr> </tbody> </table> <table background=\"#FAF9F7\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"600\" bgcolor=\"#FAF9F7\"> <tbody> <tr> <td bgcolor=\"#FAFAF8\" style=\"padding: 15px 25px 20px 25px; text-align: center; color: #000000; font-size: 24px; background-color: #FAFAF8;\">From Management.<br /></td> </tr> </tbody> </table> <table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"600\" bgcolor=\"#1F4691\"> <tbody> <tr> <td bgcolor=\"#1F4691\" style=\"padding:10px 10px 10px 10px;text-align:center; line-height:22px; color: #FFFFFF\"> {footer}</td> </tr> </tbody> </table></td> </tr></table></body></html>";
            Email  email       = new Email()
            {
                Body = body, Subject = "A Review Has Been Submitted", Comments = TxtComments.Text, CheckoutDate = user.CheckOutDate, CustName = user.LastName, ToAddress = hotel.Email, ProblemValue = HdnRating.Value, UserEmail = user.Email, ProblemText = HdnProblemTypeText.Value, Phone = user.Phone
            };

            HotelBusinessLayer.Utilities.SendEmail(email, true, image);
        }
示例#7
0
        public static void SendEmail(Email email, bool isRating = false, HotelDBApp.Image image = null)
        {
            //SmtpClient smtpClient = new SmtpClient("localhost")
            //{
            //    Credentials = new System.Net.NetworkCredential("*****@*****.**", "Intern@123"),

            //    DeliveryMethod = SmtpDeliveryMethod.Network,
            //    EnableSsl = true
            //};
            //MailMessage mail = new MailMessage
            //{

            //    //Setting From , To and CC
            //    From = new MailAddress("*****@*****.**", "Experience Hotel App")
            //};
            //mail.To.Add(new MailAddress("*****@*****.**"));
            ////mail.CC.Add(new MailAddress("*****@*****.**"));

            //smtpClient.Send(mail);
            Execute(email, isRating, image);
        }