Beispiel #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.");
            }
        }
Beispiel #2
0
        public EmailManager(EmailConfiguration configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            this.configuration = configuration;

            Init(configuration);
        }
Beispiel #3
0
        private void Init(EmailConfiguration configuration)
        {
            if (smtpClient == null)
            {
                lock (syncRoot)
                {
                    if (smtpClient == null)
                    {
                        smtpClient = new SmtpClient();
                        smtpClient.Host = configuration.SmtpAddress;
                        smtpClient.Credentials = configuration.Credentials;

                        smtpClient.SendCompleted += new SendCompletedEventHandler(smtpClient_SendCompleted);
                    }
                }
            }
        }