public ActionResult ReplyMail(MailServiceViewModel mailModel, string email)
        {
            try
            {
                SmtpClient smtpClient = new SmtpClient("smtp.gmail.com", 587);
                smtpClient.Credentials = new NetworkCredential("*****@*****.**", "~Aa123456");
                smtpClient.EnableSsl   = true;


                MailMessage mailMessage = new MailMessage();
                mailMessage.From = new MailAddress(mailModel.From);
                mailMessage.To.Add(new MailAddress(email));
                mailMessage.Subject = mailModel.Subject;
                mailMessage.Body    = mailModel.Body;
                smtpClient.Send(mailMessage);

                TempData["msg"] = "Mail has been send successfully";
                return(RedirectToAction("GetMessage"));
            }
            catch (Exception ex)
            {
                ExceptionMessage(ex);
                return(View("Error", new HandleErrorInfo(ex, "Queue", "ReplyMail")));
            }
        }
 public ActionResult ReplyMail(string email)
 {
     try
     {
         MailServiceViewModel mailModel = new MailServiceViewModel();
         ViewBag.Email = email;
         return(View(mailModel));
     }
     catch (Exception ex)
     {
         ExceptionMessage(ex);
         return(View("Error", new HandleErrorInfo(ex, "Queue", "GetMessage")));
     }
 }
Beispiel #3
0
        public ActionResult Create([Bind(Include = "Id,To,Subject,Body")] MailServiceViewModel mailServiceViewModel, HttpPostedFileBase uploadFile)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    MailService mailService = Mapper.Map <MailService>(mailServiceViewModel);
                    mailService.MailSendingDateTime = DateTime.Now;
                    mailService.From = "*****@*****.**";

                    //var result = _mailServiceManager.Add(mailService);
                    //if (result)
                    //{
                    SmtpClient smtpClient = new SmtpClient("smtp.gmail.com", 587);
                    smtpClient.Credentials = new NetworkCredential("*****@*****.**", "~Aa123456");
                    smtpClient.EnableSsl   = true;


                    MailMessage mailMessage = new MailMessage();
                    mailMessage.From = new MailAddress("*****@*****.**");
                    mailMessage.To.Add(mailService.To);
                    mailMessage.Subject = mailService.Subject;
                    mailMessage.Body    = mailService.Body;
                    if (uploadFile != null)
                    {
                        string fileName = Path.GetFileName(uploadFile.FileName);

                        mailMessage.Attachments.Add(new Attachment(uploadFile.InputStream, fileName));
                    }
                    smtpClient.Send(mailMessage);

                    TempData["msg"] = "Mail has been save and send successfully";
                    return(RedirectToAction("Index"));

                    //}
                    //ViewBag.RequisitionId = new SelectList(_requisitionManager.GetAllWithEmployee(), "Id", "RequisitionNumber", mailServiceViewModel.RequisitionId);
                    //return View(mailServiceViewModel);
                }

                //ViewBag.RequisitionId = new SelectList(_requisitionManager.GetAllWithEmployee(), "Id", "RequisitionNumber", mailServiceViewModel.RequisitionId);
                return(View(mailServiceViewModel));
            }
            catch (Exception ex)
            {
                ExceptionMessage(ex);
                return(View("Error", new HandleErrorInfo(ex, "MailServices", "Create")));
            }
        }
Beispiel #4
0
        // GET: MailServices/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            MailService mailService = _mailServiceManager.FindById((int)id);

            if (mailService == null)
            {
                return(HttpNotFound());
            }
            MailServiceViewModel mailServiceViewModel = Mapper.Map <MailServiceViewModel>(mailService);

            return(View(mailServiceViewModel));
        }
Beispiel #5
0
        public ActionResult Create([Bind(Include = "Id,To,Subject,Body")] MailServiceViewModel mailServiceViewModel)
        {
            if (ModelState.IsValid)
            {
                MailService mailService = Mapper.Map <MailService>(mailServiceViewModel);
                mailService.MailSendingDateTime = DateTime.Now;
                mailService.From = "*****@*****.**";
                var result = _mailServiceManager.Add(mailService);
                if (result)
                {
                    try
                    {
                        SmtpClient smtpClient = new SmtpClient("smtp.gmail.com", 587);
                        smtpClient.Credentials = new NetworkCredential("*****@*****.**", "~Aa123456");
                        smtpClient.EnableSsl   = true;


                        MailMessage mailMessage = new MailMessage();
                        mailMessage.From = new MailAddress("*****@*****.**");
                        mailMessage.To.Add(mailService.To);
                        mailMessage.Subject = mailService.Subject;
                        mailMessage.Body    = mailService.Body;
                        smtpClient.Send(mailMessage);

                        TempData["msg"] = "Mail has been save and send successfully";
                        return(RedirectToAction("Index"));
                    }
                    catch (Exception ex)
                    {
                        TempData["msg1"] = "Mail sending failed. The error message is -" + "<br/>" + " [ " + ex.Message + " Helpline" + " ] ";

                        return(RedirectToAction("Index"));
                    }
                }

                //ViewBag.RequisitionId = new SelectList(_requisitionManager.GetAllWithEmployee(), "Id", "RequisitionNumber", mailServiceViewModel.RequisitionId);
                return(View(mailServiceViewModel));
            }

            ViewBag.RequisitionId = new SelectList(_requisitionManager.GetAllWithEmployee(), "Id", "RequisitionNumber", mailServiceViewModel.RequisitionId);
            return(View(mailServiceViewModel));
        }
Beispiel #6
0
 // GET: MailServices/Details/5
 public ActionResult Details(int?id)
 {
     try
     {
         if (id == null)
         {
             return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
         }
         MailService mailService = _mailServiceManager.FindById((int)id);
         if (mailService == null)
         {
             return(HttpNotFound());
         }
         MailServiceViewModel mailServiceViewModel = Mapper.Map <MailServiceViewModel>(mailService);
         return(View(mailServiceViewModel));
     }
     catch (Exception ex)
     {
         ExceptionMessage(ex);
         return(View("Error", new HandleErrorInfo(ex, "MailServices", "Details")));
     }
 }