EnableEvents Property


MailBee.POP3 object is capable of background processing, so the program's user interface does not hang, and responds to Windows events - this is called "Async mode".

Also, MailBee.POP3 object can fire events itself during long-run operations such as receiving message or headers - this is called "Event firing".

When events are turned on, you can abort current operation by calling POP3.Abort method (for example, in CommandClick Sub of Cancel button) or by setting Proceed=False in POP3 event handler (OnReceiveStart, OnReceiveProgress, etc).

By default events are turned off because their usage slightly reduces performance. Set EnableEvents to True to enable events. You can then disable them by turning EnableEvents back to False.

Order of firing POP3 events is as following:

Note: To use events firing in VB, you also need to check MailBee type library in Project/References and create MailBee.POP3 object using "WithEvents" syntax (see an example below). To enable Async mode only, it's enough to set EnableEvents=True (WithEvents syntax is not necessarily required).


Value Type: Boolean
Parameters: None 
Remarks: Events are useful in event-driven environments only (such as VB, VBA, Delphi, etc). ASP pages cannot handle events

Usage example:

Option Explicit
Dim WithEvents objPOP3 As MailBee.POP3

Private Sub Form_Load()
  Dim Msgs As MailBee.Messages
  Set objPOP3 = New MailBee.POP3
  objPOP3.LicenseKey = "put your license key here"
  objPOP3.EnableEvents = True
  If objPOP3.Connect ("mailserver.com", 110, "MyName", "MyPassword") Then
    Set Msgs = objPOP3.RetrieveHeaders
    objPOP3.Disconnect
  End If
End Sub

Private Sub objPOP3_OnMessageComplete(ByVal Index As Long, Proceed As Boolean)
  MsgBox "Message " & Index & " done"
End Sub

See Also:

Abort Method
OnReceiveStart Event
OnReceiveProgress Event
OnReceiveComplete Event
OnMessageComplete Event


Copyright © 2002-2022, AfterLogic Corporation. All rights reserved.