Ejemplo n.º 1
0
        public static void SendEmail(string action, ref NewsCBTT objNews, string ExpertEmail, string CC)
        {
            // Gửi mail thông báo sự kiện
            try
            {
                string Url     = "";
                string noidung = "";
                Url = objNews.URL;
                //Lấy mail gửi theo miền
                string email = CConfig.EmailHN;
                if (ExpertEmail != null || ExpertEmail != "")
                {
                    email = ExpertEmail;
                }

                if (action == CConfig.SuaTin)
                {
                    noidung = "<b>Sự kiện cập nhật -</b> <a href=\"" + @CConfig.TEMPLATE_URL_HOST + objNews.URL.Replace("|", "") + "\">" + objNews.Stock_Code + ": " + objNews.Title + "</a> (" + DateTime.Now.ToString() + ")";
                }
                if (action == CConfig.ThemTin)
                {
                    noidung = "<b>Sự kiện thêm -</b> <a href=\"" + @CConfig.TEMPLATE_URL_HOST + objNews.URL.Replace("|", "") + "\">" + objNews.Stock_Code + ": " + objNews.Title + "</a> (" + DateTime.Now.ToString() + ")";
                }
                if (action == CConfig.XoaTin)
                {
                    noidung = "<b>Sự kiện xóa -</b> " + objNews.Stock_Code + ": " + objNews.Title + " (" + DateTime.Now.ToString() + ")";
                }
                string strTemplatePath = System.Web.Hosting.HostingEnvironment.MapPath(CConfig.FILE_TEMPLATE_EMAIL_NOTIFICATION_UPLOAD);                          // Template Html
                string strSubject      = CConfig.TEMPLATE_HTML_NOTIFICATION_UPLOAD_SUBJECT.Replace("(!Symbol)", objNews.Stock_Code).Replace("(!Action)", action); //  tieu de email
                string strBody         = CBase.ReadFile(strTemplatePath).Replace("<!Content>", noidung);                                                          // noi dung email
                                                                                                                                                                  //  LogFile.Info("1:" + strTemplatePath + "2:" + strSubject + "3:" + strBody);   // Ghi thông tin ra file
                SendEmailNotification(email, CC, strSubject, strBody);
            }
            catch (Exception ex)
            {
                LogFile.Error(ex.ToString());   // Ghi thông tin ra file
            }
        }