Abort Method


Aborts currently performed long-run operation and immediately disconnects from the IMAP4 server. If no long-run operation is currently performed, the method does nothing.

Long-run operation is any action which causes data exchange with the IMAP4 server. Connecting to the server, retrieving messages or envelopes, graceful disconnecting, etc. are all long-run operations.

To determine whether long-run operation is currently performing, examine Busy property value.

When long-run operation is aborted, rough disconnection procedure takes place (not graceful one) so "LOGOUT" IMAP4 command is not executed. However, unlike POP3 (where "QUIT" command also expunges messages marked for deletion), IMAP4 "LOGOUT" command just disconnects from the server and does nothing more. To confirm expunging messages from IMAP4 mailbox, issue Expunge or ExpungeAndClose command.

Once the connection is aborted, ErrCode property of IMAP4 object is set to value of 7 (Connection aborted by client side).

Note: Abort method can be called only if IMAP4.EnableEvents=True (Async mode is on). Calling Abort method does not immediately closes the connection, it just notifies IMAP4 object to close it. Closing itself occurs after millisecond or so after calling Abort method. This is a specificity of Async mode operation.


blnResult = ObjectName.Abort  
Parameters: None 
Return value As Boolean True if successful, False if error has occurred (nothing to abort because there is no long-run operation in progress)  

Usage example:

Option Explicit
Dim objIMAP4 As Object

Private Sub Command1_Click()
  Dim Envelopes As Object
  Set objIMAP4 = CreateObject("MailBee.IMAP4")
  objIMAP4.LicenseKey = "put your license key here"
  objIMAP4.EnableEvents = True ' Enable asynchronous 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

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:

Busy Property
EnableEvents Property
ErrCode Property

Expunge Method
ExpungeAndClose Method


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