Пример #1
0
 /// <summary>
 /// Sends an email message given a predefined string
 /// </summary>
 /// <param name="message">The string to write as the email message</param>
 public override void Write(string message)
 {
     EmailMessage mailMessage =
         new EmailMessage(toAddress, fromAddress, subjectLineStarter, subjectLineEnder, smtpServer, smtpPort, message, this.Formatter, authenticationMode, userName, password, useSSL);
     mailMessage.Send();
 }
Пример #2
0
 /// <summary>
 /// Delivers the trace data as an email message.
 /// </summary>
 /// <param name="eventCache">The context information provided by <see cref="System.Diagnostics"/>.</param>
 /// <param name="source">The name of the trace source that delivered the trace data.</param>
 /// <param name="eventType">The type of event.</param>
 /// <param name="id">The id of the event.</param>
 /// <param name="data">The data to trace.</param>
 public override void TraceData(TraceEventCache eventCache, string source, TraceEventType eventType, int id, object data)
 {
     if ((this.Filter == null) || this.Filter.ShouldTrace(eventCache, source, eventType, id, null, null, data, null))
     {
         if (data is MsgEntry)
         {
             EmailMessage message = new EmailMessage(toAddress, fromAddress, subjectLineStarter, subjectLineEnder, smtpServer, smtpPort, data as MsgEntry, this.Formatter, authenticationMode, userName, password, useSSL);
             message.Send();
         }
         else if (data is string)
         {
             Write(data);
         }
         else
         {
             base.TraceData(eventCache, source, eventType, id, data);
         }
     }
 }