Esempio n. 1
0
        private static EmailContent CreateEmailTemplate(string file)
        {
            if (!File.Exists(file))
            {
                return(null);
            }

            StreamReader sr    = new StreamReader(file);
            EmailContent email = new EmailContent();

            email.Title    = sr.ReadLine().Replace("-> ", "");
            email.Body     = sr.ReadLine().Replace("-> ", "");
            email.TableRow = sr.ReadLine().Replace("-> ", "");
            sr.Close();
            return(email);
        }
Esempio n. 2
0
        public static void RefreshData()
        {
            if (dics == null)             // load files when first time calling
            {
                dics = new Dictionary <string, EmailContent>();
            }
            else
            {
                dics.Clear();
            }

            if (string.IsNullOrEmpty(apPath))
            {
                throw new Exception("apPath is not set");
            }

            templdatesFolders = Path.Combine(apPath, templdatesFolders);

            foreach (string s in Enum.GetNames(typeof(EmailType)))
            {
                string       templateEmail = Path.Combine(templdatesFolders, s + ".txt");
                EmailContent email         = CreateEmailTemplate(templateEmail);
                if (email != null)
                {
                    if (!dics.ContainsKey(s))
                    {
                        dics.Add(s, email);
                    }
                    else
                    {
                        dics[s] = email;
                    }
                }
            }

            // get Email Sender configuration
            //string senderConfigFile = Path.Combine(templdatesFolders, "EmailSenderConfig.txt");
            //StreamReader sr = new StreamReader(senderConfigFile);
            //emailAccount = sr.ReadLine().Replace("-> ", "");
            //password = sr.ReadLine().Replace("-> ", "");
            //host = sr.ReadLine().Replace("-> ", "");
            emailAccount      = ConfigurationManager.AppSettings["DefaultEmailAccount"];
            password          = ConfigurationManager.AppSettings["DefaultEmailPassword"];
            host              = ConfigurationManager.AppSettings["SMPTHost"];
            timeFormatInEmail = ConfigurationManager.AppSettings["TimeFormatInEmail"];
            carsAddress       = ConfigurationManager.AppSettings["CARSAddress"];
        }