Пример #1
0
        public ActionResult Complaint()
        {
            string CompNo = DateTime.Now.Date.Date.ToString("yy") + DateTime.Now.Date.Date.ToString("MM") + DateTime.Now.Date.Date.ToString("dd");

            ViewBag.CompNo = CompNo + GetNo(oSubmit.GetSingleData("Select isnull(max(CompID)+1,1) from tblComplaint", "0", true).ToString());

            ViewBag.Executive = new SelectList(from res in db.employees orderby res.empname select new { res.UseCode, res.empname }, "UseCode", "empname");
            //ViewBag.SubCategory = new SelectList(from a in db.itgroups where a.itgpunde != 0 where a.compcode == SessionMaster.CompCode orderby a.itgpname select new { a.itgpname, a.itgpcode }, "itgpcode", "itgpname");
            ViewBag.SubCategory = new SelectList(from a in db.itgroups where a.itgpunde == 0 where a.compcode == SessionMaster.CompCode orderby a.itgpname select new { a.itgpname, a.itgpcode }, "itgpcode", "itgpname");

            ViewBag.vwState   = new SelectList(from a in db.citydets where a.cityType == 67 && a.cityrute == 3 orderby a.cityname select new { a.citycode, a.cityname }, "citycode", "cityname");
            ViewBag.vbService = new SelectList(from a in db.studdets where a.studType == 873 select new { a.studCode, a.studName }, "studCode", "studName");

            return(PartialView("Complaint"));
        }
Пример #2
0
        public ActionResult SendMail(string PartyIDs, int CompCode, string From, string To, int Port, string Srv)
        {
            try
            {
                string         Msg = "";
                clsSubmitModel oSubmit = new clsSubmitModel();
                string         sMSG = "Dear Sir,</br> Please Check Attachments </br></br> Thank you </br></br> <b>Tanishk Electronics </b>";
                string         Email = ""; string sPath = "";
                string[]       Row = PartyIDs.Split(',');
                //string[] Col;

                sPath = Server.MapPath("~/UploadImg/Ledger");

                System.IO.DirectoryInfo di = new DirectoryInfo(sPath);
                foreach (FileInfo file in di.GetFiles())
                {
                    System.GC.Collect();
                    System.GC.WaitForPendingFinalizers();
                    //System.IO.File.Delete();

                    file.Delete();
                }

                foreach (string itm in Row)
                {
                    if (itm != "")
                    {
                        try
                        {
                            LedgerPrint(From, To, itm, 1, CompCode);

                            //Email = "*****@*****.**";
                            Email = oSubmit.GetSingleData("Select Email from Account a inner join tblDistributor b on a.acctdeal = b.mstCode where a.acctCode = " + itm).ToString();
                            if (Email.ToString().Length > 6)
                            {
                                //SmtpClient smtpClient = new SmtpClient("mi3-wts5.a2hosting.com", Port); // 25 mi3-wtr1.supercp.com
                                SmtpClient smtpClient = new SmtpClient(Srv, Port); // 25
                                smtpClient.Credentials    = new System.Net.NetworkCredential("*****@*****.**", "Uvstar@11");
                                smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
                                MailMessage mailMessage = new MailMessage("*****@*****.**", Email);

                                mailMessage.Subject    = "Ledger";
                                mailMessage.IsBodyHtml = true;
                                mailMessage.Body       = sMSG;

                                sPath = Server.MapPath("~/UploadImg/Ledger/Ledger_" + itm + ".pdf");

                                mailMessage.Attachments.Add(new Attachment(sPath));

                                smtpClient.Send(mailMessage);

                                //System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
                                //SmtpClient SmtpServer = new SmtpClient("mi3-wts5.a2hosting.com", Port);
                                //mail.From = new MailAddress("*****@*****.**");
                                //mail.To.Add(Email);
                                //mail.Subject = "Enquiry";
                                //mail.IsBodyHtml = true;
                                //mail.Body = "Test".ToString();
                                //SmtpServer.Credentials = new System.Net.NetworkCredential("*****@*****.**", "Uvstar@11");
                                //SmtpServer.EnableSsl = false;
                                //SmtpServer.Send(mail);


                                Msg += "Send Successfully";

                                //if (System.IO.File.Exists(sPath))
                                //{ System.IO.File.Delete(sPath); }
                            }
                            else
                            {
                                Msg += "Email Not Proper .";
                            }
                        }
                        catch (Exception EXP)
                        {
                            Msg += EXP.Message;
                        }
                    }
                }
                return(Json(new { Success = true, Message = Msg }));
            }
            catch (Exception EX)
            {
                return(Json(new { Success = false, Message = "Something went wrong. Please try again. " + EX.Message }));
            }
        }