Пример #1
0
        public static void SendEmail(string name, ApiKey key, IDictionary values)
        {
            if (name == null)
                throw new ArgumentNullException("name");
            if (name.Length == 0)
                throw new ArgumentException("'name' is zero-length.");
            if (key == null)
                throw new ArgumentNullException("key");
            if (values == null)
                throw new ArgumentNullException("values");

            // set...
            CmsContentItem item = CmsContentItem.GetByName(name);
            if (item == null)
                throw new InvalidOperationException("'item' is null.");

            // get...
            values["key"] = key;
            MailMessage message = item.GetMailMessage(values);
            if (message == null)
                throw new InvalidOperationException("'message' is null.");

            // send...
            SmtpConnectionSettings settings = Settings.GetSmtpSettings();
            if (settings == null)
                throw new InvalidOperationException("'settings' is null.");
            ISmtpProvider provider = MailProviderFactory.GetSmtpProvider(settings);
            if (provider == null)
                throw new InvalidOperationException("'provider' is null.");

            // send...
            message.FromAsString = Settings.EmailFrom;
            message.ToAsString = key.Email;
            message.BccAsString = Settings.EmailBcc;
            provider.Send(message);
        }
 /// <summary>
 /// Adds a range of <see cref="ApiKey"/> instances to the collection.
 /// </summary>
 public void AddRange(ApiKey[] items)
 {
     base.AddRange(items);
 }
Пример #3
0
 public static void SendEmail(string name, ApiKey key)
 {
     SendEmail(name, key, CollectionsUtil.CreateCaseInsensitiveHashtable());
 }
 /// <summary>
 /// Adds a <see cref="ApiKey"/> instance to the collection.
 /// </summary>
 public int Add(ApiKey item)
 {
     return base.Add(item);
 }