Example #1
0
        public static void NotifyNewComment(NotificationConfiguration config, string subject, string body)
        {
            if (config.NotifyOnComment &&
                !string.IsNullOrEmpty(config.NotifyToEmail))
            {
                //check for notificaiton email.
                EmailConfiguration configuration = new EmailConfiguration();
                try
                {
                    configuration.Configure(config.SmtpAddress, config.SmtpUserName, config.SmtpPassword, config.FromAddress);
                    EmailManager manager = new EmailManager(configuration);
                    manager.SendAsync(string.Empty, config.NotifyToEmail, subject, body);
                }
                catch (ArgumentException)
                {
                    //not configured correctly
                    logger.Log(LogLevel.Debug, "Unable to notify on new comment. Please check SMTP settings.");
                }

            }
            else
            {
                logger.Log(LogLevel.Debug, "Unable to notify on new comment. NotifyOnComment is off or receiver email address is not set.");
            }
        }
        public static void Update(NotificationConfiguration configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            logger.Log(LogLevel.Debug, "Saving notification configuration");

            PluginStore.Instance.Save(Instance, configuration);
        }
        public static NotificationConfiguration Read()
        {
            int siteId = WebContext.Current.Site.Id;
            NotificationConfiguration configuration = NotificationConfigurationPlugin.Instance.Read(siteId);

            if (configuration == null)
            {
                logger.Log(LogLevel.Info, "NotificationConfiguration does not exist for SiteId : {0}. Saving one", siteId);
                configuration = new NotificationConfiguration(siteId);
                NotificationConfigurationPlugin.Instance.Save(configuration);
            }

            return configuration;
        }
Example #4
0
 private void RenderSmtpValues(NotificationConfiguration config)
 {
     this.smtpaddress.Value = config.SmtpAddress;
     this.smtpusername.Value = config.SmtpUserName;
     this.fromemail.Value = config.FromAddress;
 }