Beispiel #1
0
        /// <summary>
        /// 自定发送
        /// </summary>
        public bool SendReport2()
        {
            bool flag = true;

            MailMessage mail       = new MailMessage();
            SmtpClient  smtpServer = new SmtpClient();



            //Hanbell.Common.Mail.MailInfo mailInfo = new Hanbell.Common.Mail.MailInfo();
            //mailInfo.Sender = "*****@*****.**";

            Hanbell.Common.Xml.XmlHelp xmlHelp = new Hanbell.Common.Xml.XmlHelp();
            xmlHelp.XmlPath = "config\\common\\smtpSetting.xml";
            //mailInfo.Receiver = "*****@*****.**";
            // mailInfo.Receiver = "[email protected];";


            //[email protected];[email protected];

            //mailInfo.Subject = Subject;

            string bodyHtml = Hanbell.Common.Mail.HtmlUtil.ReadHtml(base.TmpName);

            //bodyHtml = bodyHtml.Replace("${qtyTable}", QtyHtml)
            //                   .Replace("${amtTable}", AmtHtml)
            //                   .Replace("${nowdate}", RptDateTime.ToString("yyyy-MM-dd"))
            //                   .Replace("${nowdatetime}", DateTime.Now.ToString("yyyy-MM-dd"))
            //                   .Replace("${tableTiltle}", TableTiltle)
            //                   .Replace("${mark}", Hmark);

            bodyHtml = bodyHtml.Replace("${rptR}", HTM_R)
                       .Replace("${rptAA}", HTM_AA)
                       .Replace("${rptAH}", HTM_AH)
                       .Replace("${rptP}", HTM_P)
                       .Replace("${rptCM}", HTM_CM)
                       .Replace("${rptALL}", HTM_ALL)
                       .Replace("${nowdate}", RptDateTime.ToString("yyyy-MM-dd"))
                       .Replace("${nowdatetime}", DateTime.Now.ToString("yyyy-MM-dd"))
                       .Replace("${tableTiltle}", TableTiltle);
            //.Replace("${mark}", Hmark);


            //mailInfo.Body = bodyHtml;

            //flag = Hanbell.Common.Mail.MailSender.CreateMailSender.SendMail(mailInfo, Hanbell.Common.Mail.BodyType.BodyHtml);


            mail.From = new MailAddress("*****@*****.**");//发件人地址
            mail.To.Add(new MailAddress("*****@*****.**"));
            mail.IsBodyHtml        = true;
            mail.Body              = bodyHtml;
            smtpServer.Host        = "172.16.10.18";
            smtpServer.Credentials = new System.Net.NetworkCredential("*****@*****.**", "123456");
            smtpServer.Send(mail);
            return(flag);
        }
Beispiel #2
0
        /// <summary>
        /// 自定发送
        /// </summary>
        public bool SendReport2()
        {
            bool flag = true;

            MailMessage mail       = new MailMessage();
            SmtpClient  smtpServer = new SmtpClient();



            //Hanbell.Common.Mail.MailInfo mailInfo = new Hanbell.Common.Mail.MailInfo();
            //mailInfo.Sender = "*****@*****.**";

            Hanbell.Common.Xml.XmlHelp xmlHelp = new Hanbell.Common.Xml.XmlHelp();
            xmlHelp.XmlPath = "config\\common\\smtpSetting.xml";
            //xmlHelp.XmlDom[
            //mailInfo.Receiver = "*****@*****.**";
            // mailInfo.Receiver = "[email protected];";


            //[email protected];[email protected];

            //mailInfo.Subject = Subject;

            string bodyHtml = Hanbell.Common.Mail.HtmlUtil.ReadHtml(base.TmpName);

            //bodyHtml = bodyHtml.Replace("${qtyTable}", QtyHtml)
            //                   .Replace("${amtTable}", AmtHtml)
            //                   .Replace("${nowdate}", RptDateTime.ToString("yyyy-MM-dd"))
            //                   .Replace("${nowdatetime}", DateTime.Now.ToString("yyyy-MM-dd"))
            //                   .Replace("${tableTiltle}", TableTiltle)
            //                   .Replace("${mark}", Hmark);

            bodyHtml = bodyHtml.Replace("${rptR_MB}", HTM_R_MB).Replace("${rptR_SJ}", HTM_R_SJ).Replace("${rptR_KZL}", HTM_R_KZL)
                       .Replace("${rptAA_MB}", HTM_AA_MB).Replace("${rptAA_SJ}", HTM_AA_SJ).Replace("${rptAA_KZL}", HTM_AA_KZL)
                       .Replace("${rptAH_MB}", HTM_AH_MB).Replace("${rptAH_SJ}", HTM_AH_SJ).Replace("${rptAH_KZL}", HTM_AH_KZL)
                       .Replace("${rptP_MB}", HTM_P_MB).Replace("${rptP_SJ}", HTM_P_SJ).Replace("${rptP_KZL}", HTM_P_KZL)
                       .Replace("${rptCM_MB}", HTM_CM_MB).Replace("${rptCM_SJ}", HTM_CM_SJ).Replace("${rptCM_KZL}", HTM_CM_KZL)
                       .Replace("${rptALL_MB}", HTM_ALL_MB).Replace("${rptALL_SJ}", HTM_ALL_SJ).Replace("${rptALL_KZL}", HTM_ALL_KZL)
                       .Replace("${nowdate}", RptDateTime.ToString("yyyy-MM-dd"))
                       .Replace("${nowdatetime}", DateTime.Now.ToString("yyyy-MM-dd"))
                       .Replace("${tableTiltle}", TableTiltle);
            //.Replace("${mark}", Hmark);


            //mailInfo.Body = bodyHtml;

            //flag = Hanbell.Common.Mail.MailSender.CreateMailSender.SendMail(mailInfo, Hanbell.Common.Mail.BodyType.BodyHtml);

            string From     = xmlHelp.XmlDom.DocumentElement.SelectNodes("user")[0].InnerText;//发件人地址
            string Host     = xmlHelp.XmlDom.DocumentElement.SelectNodes("server")[0].InnerText;
            string PassWord = xmlHelp.XmlDom.DocumentElement.SelectNodes("password")[0].InnerText;
            string To       = xmlHelp.XmlDom.DocumentElement.SelectNodes("To")[0].InnerText;

            mail.From = new MailAddress(From);//发件人地址
            mail.To.Add(new MailAddress(To));
            mail.IsBodyHtml        = true;
            mail.Body              = bodyHtml;
            smtpServer.Host        = Host;
            smtpServer.Credentials = new System.Net.NetworkCredential(From, PassWord);
            smtpServer.Send(mail);
            return(flag);
        }