ExpungeAndClose Method


Permanently removes all messages marked as "deleted" and closes currently selected mailbox.

If this method is not called before disconnecting or selecting another mailbox, messages marked as "deleted" are not removed. However, their "deleted" flag is not discarded.


blnResult = ObjectName.ExpungeAndClose  
Parameters: None 
Return value As Boolean True if successful, False if error has occurred. You can check ErrDesc property or log file to get more detailed error information  

Usage example:

' This sample permanently deletes all messages from "Inbox" that
' have "deleted" flag set during previous sessions.

Dim Mailer
'Using visual basic to create object
Set Mailer = CreateObject("MailBee.IMAP4")
'Using ASP to create object
'Set Mailer = Server.CreateObject("MailBee.IMAP4")
'In ASP use Response.Write instead of MsgBox

Mailer.EnableLogging = True ' Logging helps to discover any problems
Mailer.LogFilePath = "C:\Temp\imap4_log.txt"

Mailer.LicenseKey = "put your license key here"
If Mailer.Connect("mailserver.com", 143, "MyName", "MyPassword") Then
  If Mailer.SelectMailbox("Inbox") Then
    If Mailer.ExpungeAndClose Then
      MsgBox "Messages expunged successfully. Mailbox closed"
    End If
  End If
  Mailer.Disconnect
Else
  MsgBox Mailer.ErrDesc
End If

See Also:

DeleteMessages Method
Expunge Method
SelectMailbox Method


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