void LogMessage(GeneratedMessage message, StringDictionary newheaders)
        {
            var text = new StringBuilder();

            text.AppendLine("GENERATED message\r\n");
            foreach (string key in newheaders.Keys)
            {
                text.AppendLine(key + ":" + newheaders[key] + "\r\n");
            }
            text.AppendLine("Subj:" + Environment.NewLine + message.Subject + Environment.NewLine + "Body:" + Environment.NewLine + message.Body);
            Logger.WriteTrace(text.ToString(), SeverityEnum.Trace);
        }
        /// <summary>
        /// On alert notification
        /// </summary>
        /// <param name="web">current web</param>
        /// <param name="eventArgs">params of alert and event</param>
        /// <returns>Generated cutom message</returns>
        public SEMessage OnNotification(SPWeb web, SPAlertHandlerParams eventArgs)
        {
            SPList list    = null;
            var    eventID = Guid.NewGuid();

            if (eventArgs.a != null)
            {
                if (eventArgs.eventData.Length == 1)
                {
                    GeneratedMessage message = null;
                    var receiverEmail        = eventArgs.headers["to"];
                    var ed = eventArgs.eventData[0];
                    list = web.Lists[eventArgs.a.ListID];
                    try
                    {
                        message = GetMessageForItem(eventID, list, ed.itemId, (SPEventType)ed.eventType, ed.eventXml, ed.modifiedBy, receiverEmail, eventArgs.a.UserId);
                    }
                    catch (SeTemplateNotFound ex)
                    {
                        Application.Current.Logger.WriteTrace("TEMPLATE NOT FOUND", ex, SharePointEmails.Logging.SeverityEnum.Verbose);
                    }
                    catch (Exception ex)
                    {
                        Application.Current.Logger.WriteTrace("ERROR DURING GETTING MESSAGE", SharePointEmails.Logging.SeverityEnum.Verbose);
                        throw;
                    }
                    if (message != null)
                    {
                        var mail = SEMessage.Create(eventID, message, eventArgs.headers, eventArgs.body);

                        Application.Current.Logger.WriteTrace("Message will be sent sent", SharePointEmails.Logging.SeverityEnum.Verbose);

                        var processor = ProcessorsManager.Instance.CreateOutcomingProcessor(list);
                        if (processor != null)
                        {
                            processor.Precess(mail, ed);
                        }

                        LogMessage(message, mail.headers);
                        return(mail);
                    }
                    else
                    {
                        Application.Current.Logger.WriteTrace("Message not generated", SharePointEmails.Logging.SeverityEnum.Verbose);
                    }
                }
                else
                {
                    Application.Current.Logger.WriteTrace("OnNotification - More then 1 eventdata. currently not supported", SharePointEmails.Logging.SeverityEnum.Warning);
                }
            }
            return(null);
        }