OnEnvelopeDownloaded Event
Fires when IMAP4 object parses an envelope (FETCH response) in the data received from the IMAP server.
This event lets you get e-mail messages with their envelopes not waiting for the entire operation to complete. This only makes sense when you download multiple messages at once.
Parameters: | ||
DataLength As Long | Received envelope size in bytes | |
EnvelopeDownloaded As Envelope | Received envelope | |
MessageNumber As Long | Ordinal number (index) of the downloaded message in the mailbox. The first e-mail in the mailbox has index=1. | |
ByRef Proceed As Boolean | Default value is True, which tells MailBee to continue processing. You can set it to False to immediately abort IMAP4 session and disconnect from IMAP4 server | |
Remarks: | Events are turned off by default. To enable them, set EnableEvents to True |
Usage example:
Option Explicit ' Early binding and "WithEvents" syntax required for handling MailBee's events Dim WithEvents objIMAP4 As MailBee.IMAP4 Private Sub Command1_Click() Dim Envelopes As MailBee.Envelopes Set objIMAP4 = CreateObject("MailBee.IMAP4") objIMAP4.LicenseKey = "put your license key here" objIMAP4.EnableEvents = True ' Enable Async mode If objIMAP4.Connect("mailserver.com", 143, "MyName", "MyPassword") Then ' Long-run operation If objIMAP4.SelectMailbox("Inbox") Then ' Long-run operation Set Envelopes = objIMAP4.RetrieveEnvelopes(1, objIMAP4.MessageCount, False) ' Long-run operation End If objIMAP4.Disconnect ' Long-run operation End If End Sub ' Respond to MailBee's OnEnvelopeDownloaded event and print Subject of the messages being received Private Sub objIMAP4_OnReceiveData(ByVal DataLength As Long, ByVal EnvelopeDownloaded As MailBee.Envelope, ByVal MessageNumber As Long, Proceed As Boolean) Debug.Print EnvelopeDownloaded.Subject
End Sub Private Sub Form_Load() Set objIMAP4 = Nothing End Sub Private Sub Form_Unload(Cancel As Integer) If objIMAP4 Is Nothing Then Exit Sub If objIMAP4.Busy Then objIMAP4.Abort ' Cancel IMAP4 session on exit End Sub
See Also:
EnableEvents
Property
OnReceiveData Event
Copyright © 2002-2024, AfterLogic Corporation. All rights reserved.