GetLastReceivedDataChunk Method


Gets the last received data block of the server's response as a string.

Typically, you'll use this method in OnReceiveData event handler to monitor the data being received during the connection. Typically, 5-60KB data portion is returned per call. For instance, if you're downloading 1MB e-mail, OnReceiveData event will fire about 30-200 times as the overall data is split in 30-200 chunks.

The method should be called once per a single triggering of OnReceiveData event.


strData = ObjectName.GetLastReceivedDataChunk()  
Parameters: None 
Return value As String Data portion received with the last read data operation.  

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 OnReceiveData event and print the actual data received
Private Sub objIMAP4_OnReceiveData(ByVal BytesReceived As Long, Proceed As Boolean)
  Debug.Print objIMAP.GetLastReceivedDataChunk
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:

OnReceiveData Event


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