mail::account::copyMessagesTo — Copy messages to another folder


#include <libmail/mail.H>

class myCallback : public mail::callback {
    void success(std::string msg);
    void fail(std::string msg);

account->copyMessagesTo( const std::vector<size_t> &msgList,
  mail::folder *copyTo,
  myCallback &callback);


mail::account::copyMessagesTo copies messages in the currently-open folder to another folder. msgList specifies a list of messages. Messages are numbered starting with message #0 and up to one less than mail::account::getFolderIndexSize(3x)() (when mail::account::getFolderIndexSize returns 6, the messages are numbered 0 through 5). Only the messages that appear in msgList are processed by this request.

copyTo is a pointer to a mail::folder object, representing the folder where messages are copied to. If account is an IMAP account and copyTo is another folder in the same account, then the messages are quickly copied by the IMAP server. Otherwise each message is individually downloaded and copied to the copyTo folder.

Return Codes

The application must wait until callback's success or fail method is invoked. The success method is invoked when this request is succesfully processed. The fail method is invoked if this request cannot be processed. The application must not destroy callback until either the success or fail method is invoked.


callback's fail method may be invoked even after other callback methods were invoked. This indicates that the request was partially completed before the error was encountered.


Multiple applications may have the same account and folder opened at the same time. It is possible that a message referenced by this request was already deleted by another application. Depending on the underlying server implementation this will result in either a failed request, invoking, or the request completing (callback.success invoked) but without invoking any callback function that refer to the message.