Pop3LogNewEntry Event
Occurs when an entry is written into the log file (or into the memory buffer if Pop3.Log.MemoryLog is true).

Namespace: MailBee.Pop3Mail
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 12.5.0 build 687 for .NET 4.5
Syntax
public event LogNewEntryEventHandler LogNewEntry

Value

Type: MailBeeLogNewEntryEventHandler
Remarks

This event is raised only if logging is turned on (Enabled is true).

MailBee raises this event BEFORE adding the entry into the the log. Since many properties of NewEntry object are editable, the developer can change the data MailBee will put into the log or even cancel logging the current entry at all. This may be useful the developer wishes to log only those entires which meet certain criteria.

Note Note
Entries added by the developer (through WriteLine(String) method call) do not cause this event to be raised. Thus, it's safe to add user-defined log entries even in the LogNewEntry event handler itself. This does not cause endless recursion which would otherwise occur if WriteLine(String) method called in LogNewEntry event handler raised this event again.
Examples
This sample enables logging the POP3 session into a file, and logs only those entries which indicate any data traffic between the client (MailBee) and the server. Other entries are discarded, and user-defined log entry is added instead. The sample is written for a console application.
using System;
using MailBee;
using MailBee.Pop3Mail;

class Sample
{
    // LogNewEntry event handler.
    private static void OnLogNewEntry(object sender, LogNewEntryEventArgs e)
    {
        if ( !(e.NewEntry.MessageType == LogMessageType.Recv ||
            e.NewEntry.MessageType == LogMessageType.Send) )
        {
            // Do not add this entry if it does not indicate any data transfer,
            // and put our own message instead.
            e.NewEntry.AddThisEntry = false;
            ((Pop3)sender).Log.WriteLine("UNWANTED MESSAGE REMOVED");

            // Note: we could produce similar results just by writing new values
            // into MessageText and MessageComment properties of the original entry.
            // The code above uses Log.WriteLine method just to show how to add new
            // entries in the event handler itself. You may comment 2 code lines above
            // and uncomment 2 code lines below to use the alternate approach.
            // 
            // e.NewEntry.MessageText = "UNWANTED MESSAGE REMOVED";
            // e.NewEntry.MessageComment = string.Empty;
        }
    }

    // The actual code
    static void Main(string[] args)
    {
        Pop3 pop = new Pop3();

        // Enable logging the POP3 session into a file.
        pop.Log.Enabled = true;
        pop.Log.Filename = @"C:\Temp\log.txt";
        pop.Log.Clear();

        // Subscribe to the LogNewEntry event.
        pop.LogNewEntry += new LogNewEntryEventHandler(OnLogNewEntry);

        // Do something which would produce some network traffic.
        pop.Connect("mail.domain.com");
        pop.Login("jdoe", "secret");
        pop.Disconnect();
    }
}
See Also