Exemplo n.º 1
0
        private ComSMTP()
        {
            xml = new XMLLoader(XMLLoader.CONFIG_TYPE.SMTP_Config);
            config = (SMTPConfig)this.GetSmtpConfig().Data[0];
            message = new MailMessage();
            smtp = new SmtpClient();
            basicCredential = new NetworkCredential(config.Username, config.Password);
            smtp.UseDefaultCredentials = false;
            smtp.Credentials = basicCredential;

        }
Exemplo n.º 2
0
        public MessageSerializable.Message LoadConfig()
        {
            if (type == CONFIG_TYPE.SQL_Server_Config)
            {
                string cnx = "";
                //ReversibleEncryption.DecryptFile(SQLSERVER_CONFIG_PATH);
                XmlDocument doc = new XmlDocument();
                doc.Load(SQLSERVER_CONFIG_PATH);

                string provider = doc.DocumentElement.SelectSingleNode("/Config/Provider").InnerText;
                string dataSource = doc.DocumentElement.SelectSingleNode("/Config/DataSource").InnerText;
                string initCatalog = doc.DocumentElement.SelectSingleNode("/Config/InitialCatalog").InnerText;
                string user = doc.DocumentElement.SelectSingleNode("/Config/User").InnerText;
                string password = doc.DocumentElement.SelectSingleNode("/Config/Password").InnerText;
                
                //ReversibleEncryption.EncryptFile(SQLSERVER_CONFIG_PATH);

                cnx = "Provider=" + provider + ";Data Source=" + dataSource + ";User ID=" + user + ";Password="******";Initial Catalog=" + initCatalog + "";
                MessageSerializable.Message msg = new MessageSerializable.Message();
                msg.Data[0] = cnx;
                return msg;
            }
            else if (type == CONFIG_TYPE.SMTP_Config)
            {
                //ReversibleEncryption.DecryptFile(SMTP_CONFIG_PATH);
                XmlDocument doc = new XmlDocument();
                doc.Load(SMTP_CONFIG_PATH);

                string address = doc.DocumentElement.SelectSingleNode("/Config/Address").InnerText;
                string username = doc.DocumentElement.SelectSingleNode("/Config/Username").InnerText;
                string password = doc.DocumentElement.SelectSingleNode("/Config/Password").InnerText;
                string host = doc.DocumentElement.SelectSingleNode("/Config/Host").InnerText;
                string port = doc.DocumentElement.SelectSingleNode("/Config/Port").InnerText;
                string enableSSL = doc.DocumentElement.SelectSingleNode("/Config/EnableSSL").InnerText;
                
                //ReversibleEncryption.EncryptFile(SMTP_CONFIG_PATH);

                SMTPConfig smtp = new SMTPConfig(address, username, password, host, Convert.ToInt32(port), bool.Parse(enableSSL));
                
                MessageSerializable.Message msg = new MessageSerializable.Message();
                msg.Data[0] = smtp;
                return msg;
            }
            else
                return null;
        }