コード例 #1
0
ファイル: MailService.cs プロジェクト: volpav/toprope
        /// <summary>
        /// Handles Dispatcher "Dispatching" event.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event arguments.</param>
        private void Dispatcher_Dispatching(object sender, DispatchEventArgs e)
        {
            LogEntry entry = null;

            if (e != null && Logger != null)
            {
                if (e.Success)
                {
                    if (e.Event != null)
                        entry = e.Event;
                    else
                        entry = new LogEntry("Message has been successfully sent.", LogEntryLevel.Information);
                }
                else
                    entry = e.Event;

                if (entry != null)
                {
                    if (e.Message != null)
                    {
                        entry.Message += string.Format(" Message details (from, to[0], subject): ({0}, {1}, \"{2}\").",
                            e.Message.From.Address, e.Message.To.Any() ? e.Message.To.First().Address : "---", e.Message.Subject);
                    }

                    if (!string.IsNullOrEmpty(entry.Message))
                        entry.Message = entry.Message.Trim();

                    Logger.Log(new LogEntry[] { entry });
                }
            }
        }
コード例 #2
0
ファイル: DispatchEventArgs.cs プロジェクト: volpav/toprope
 /// <summary>
 /// Initializes a new instance of an object.
 /// </summary>
 /// <param name="message">Message being dispatched.</param>
 /// <param name="event">The log entry associated with the given dispatch operation.</param>
 public DispatchEventArgs(System.Net.Mail.MailMessage message, LogEntry @event)
 {
     this.Message = message;
     this.Event = @event;
 }