Archived Forum Post

Index of archived forum posts

Question:

IMAP Mail Copy Error

Nov 12 '12 at 03:36

I want to copy a mail via IMAP into an other folder - VB.ActiveX Code and ErrorLog see below:

'  Copy to a folder named "Gelöschte Elemente"
success = imap.Copy(Email.GetImapUid, 1, "Gelöschte Elemente")

ChilkatLog:
  Copy:
    DllDate: Aug  5 2012
    UnlockPrefix: BUNDESIMAPMAILQ
    Username: PC47052:adbm
    Architecture: Little Endian; 32-bit
    Language: ActiveX
    VerboseLogging: 0
    mailbox: Gelöschte Elemente
    utf7EncodedMailboxName: Gel&APY-schte Elemente
    Command: aaag UID COPY -1 "Gel&APY-schte Elemente"
    ImapCmdSent: aaag UID COPY -1 "Gel&APY-schte Elemente"
    getCompleteResponse:
      ImapCmdResp: aaag BAD The specified message set is invalid.
    --getCompleteResponse
    Failed to find OK line in response.
    imapCopyResponse: aaag BAD The specified message set is invalid.
    Failed.
  --Copy
--ChilkatLog

With Release 9.3.0 it worked well; with 9.3.2 I get the obove error. (The National Character "ö" in the folder name seems to make a problem.)


Answer

The problem shouldn't be the character "ö".

I noticed that the integer value -1 is used for the UID in the COPY command sent to IMAP, which tells me that the call to Email.GetImapUid must have returned -1. The problem is not with the Copy method, but with the GetImapUid method.

As an aside, if a Chilkat method can return a value indicating failure, such as -1, false, NULL, etc., then it's not a good idea to insert the method call directly into the argument list of another method call. It's better to make the call on a separate line and check for the error condition. For example:

uid = email.GetImapUid()
if (uid = -1) then
    ...
else  
success = imap.Copy(uid, 1, "Gelöschte Elemente") endif

If the GetImapUid method returns -1, it means the "ckx-imap-uid" header field was not present. If the FetchSingle method was called to download the email, see this Chilkat Forum topic for more information about it: http://www.chilkatforum.com/questions/1492/cant-delete-imap-mail-vbscript


Answer

Thanks for your hints (I use fetchbundle); the answer in
http://www.chilkatforum.com/questions/536/imap-get-uid-results-in-0
solved my problem.