CopyMessages Method


Copies one or more messages from the currently selected mailbox to another mailbox.

To copy single message, set First and Last parameters to the same message number or UID.


blnResult = ObjectName.CopyMessages(MailboxName, First, Last, AsUID)  
Parameters:  
MailboxName As String Destination mailbox name. Messages will be copied to this mailbox  
First As Long Message number or UID of the first message in copied range  
Last As String Message number or UID of the last message in copied range  
AsUID As Boolean If True, First and Last parameters must be specified as UIDs (unique-IDs). Otherwise, First and Last must be message numbers  
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 copies all messages with message numbers starting at 20 from "Inbox" folder
' into "Archive" folder. Both folders must exist.

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:\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.CopyMessages("Archive", 20, Mailer.MessageCount, False) Then
        MsgBox "Messages copied successfully"
    End If
  End If
  Mailer.Disconnect
Else
  MsgBox Mailer.ErrDesc
End If

See Also:

MessageCount Property

SelectMailbox Method


Copyright 2002-2008, AfterLogic Corporation. All rights reserved.