public void Send(IEnumerable<ContentItemRecord> recipients, string type, string service, Dictionary<string, string> properties = null)
        {
            if ( !HasChannels() )
                return;

            Logger.Information("Sending message {0}", type);
            try {
                var context = new MessageContext {
                    Recipients = recipients,
                    Type = type,
                    Service = service
                };

                PrepareAndSend(type, properties, context);
            }
            catch ( Exception e ) {
                Logger.Error(e, "An error occured while sending the message {0}", type);
            }
        }
        private void PrepareAndSend(string type, Dictionary<string, string> properties, MessageContext context)
        {
            try {
                if (properties != null) {
                    foreach (var key in properties.Keys)
                        context.Properties.Add(key, properties[key]);
                }

                _messageEventHandler.Sending(context);

                foreach (var channel in _channels) {
                    channel.SendMessage(context);
                }

                _messageEventHandler.Sent(context);
            }
            finally {
                context.MailMessage.Dispose();
            }

            Logger.Information("Message {0} sent", type);
        }
 public void SendMessage(MessageContext message)
 {
     Messages.Add(message);
 }