public EmailUtility(string settingsPath)
        {
            using (new SecurityModel.SecurityDisabler())
            {
                Database masterDb = Factory.GetDatabase(DbName);
                Item     settings = masterDb.GetItem(settingsPath);
                if (settings != null)
                {
                    this.senderAddress = string.IsNullOrEmpty(settings[SenderEmailField])
                                        ? Settings.GetAppSetting("EmailReminder.FromAddress")
                                        : settings[SenderEmailField].Trim();

                    this.senderDisplayName = settings[SenderNameField];

                    this.smtpServer = string.IsNullOrEmpty(settings[ServerField])
                                        ? Settings.MailServer
                                        : settings[ServerField].Trim();

                    //NOTE: Do we need to get default value from web.config
                    this.smtpPort = settings[PortField];
                    if (!string.IsNullOrEmpty(this.smtpPort))
                    {
                        this.smtpPort = this.smtpPort.Trim();
                    }

                    //NOTE: Do we need to get default value from web.config
                    this.userName = settings[UserNameField];

                    //NOTE: Do we need to get default value from web.config
                    this.userPassword = settings[PasswordFiled];

                    this.mailSubject = string.IsNullOrEmpty(settings[SubjectField])
                                   ? Settings.Tasks.EmailReminderSubject
                                   : settings[SubjectField];

                    this.mailBody = string.IsNullOrEmpty(settings[ItemDescField])
                                   ? Settings.Tasks.EmailReminderText
                                   : settings[ItemDescField];

                    this.mailHeader = settings[HeaderField];
                    this.mailFooter = settings[FooterField];
                }
                else
                {
                    this.senderAddress = Settings.GetAppSetting("EmailReminder.FromAddress");
                    this.smtpServer    = Settings.MailServer;
                    this.smtpPort      = Settings.MailServerPort.ToString();
                    this.userName      = Settings.MailServerUserName;
                    this.userPassword  = Settings.MailServerPassword;
                    this.mailSubject   = Settings.Tasks.EmailReminderSubject;
                    this.mailBody      = Settings.Tasks.EmailReminderText;
                }

                Assert.IsNotNullOrEmpty(this.senderAddress, "Sender isn't specified");
                Assert.IsNotNullOrEmpty(this.smtpServer, "SMTP server name isn't specified");
                Assert.IsNotNullOrEmpty(this.mailSubject, "Mail body isn't specified");
                Assert.IsNotNullOrEmpty(this.mailBody, "Mail subject isn't specified");

                this.mailConfigurator = new DefaultMailConfigurator(this.senderDisplayName);
            }
        }
        public EmailUtility(string settingsPath)
        {
            using (new SecurityModel.SecurityDisabler())
            {
                Database masterDb = Factory.GetDatabase(DbName);
                Item settings = masterDb.GetItem(settingsPath);
                if (settings != null)
                {
                    this.senderAddress = string.IsNullOrEmpty(settings[SenderEmailField])
                                        ? Settings.GetAppSetting("EmailReminder.FromAddress")
                                        : settings[SenderEmailField].Trim();

                    this.senderDisplayName = settings[SenderNameField];

                    this.smtpServer = string.IsNullOrEmpty(settings[ServerField])
                                        ? Settings.MailServer
                                        : settings[ServerField].Trim();

                    //NOTE: Do we need to get default value from web.config
                    this.smtpPort = settings[PortField];
                    if (!string.IsNullOrEmpty(this.smtpPort))
                    {
                        this.smtpPort = this.smtpPort.Trim();
                    }

                    //NOTE: Do we need to get default value from web.config
                    this.userName = settings[UserNameField];

                    //NOTE: Do we need to get default value from web.config
                    this.userPassword = settings[PasswordFiled];

                    this.mailSubject = string.IsNullOrEmpty(settings[SubjectField])
                                   ? Settings.Tasks.EmailReminderSubject
                                   : settings[SubjectField];

                    this.mailBody = string.IsNullOrEmpty(settings[ItemDescField])
                                   ? Settings.Tasks.EmailReminderText
                                   : settings[ItemDescField];

                    this.mailHeader = settings[HeaderField];
                    this.mailFooter = settings[FooterField];
                }
                else
                {
                    this.senderAddress = Settings.GetAppSetting("EmailReminder.FromAddress");
                    this.smtpServer = Settings.MailServer;
                    this.smtpPort = Settings.MailServerPort.ToString();
                    this.userName = Settings.MailServerUserName;
                    this.userPassword = Settings.MailServerPassword;
                    this.mailSubject = Settings.Tasks.EmailReminderSubject;
                    this.mailBody = Settings.Tasks.EmailReminderText;
                }

                Assert.IsNotNullOrEmpty(this.senderAddress, "Sender isn't specified");
                Assert.IsNotNullOrEmpty(this.smtpServer, "SMTP server name isn't specified");
                Assert.IsNotNullOrEmpty(this.mailSubject, "Mail body isn't specified");
                Assert.IsNotNullOrEmpty(this.mailBody, "Mail subject isn't specified");

                this.mailConfigurator = new DefaultMailConfigurator(this.senderDisplayName);
            }
        }