After a mail is moved to another folder using MAILMOVE, MAILINFO then fails.
Here is an example:
-----
'MAILLISTFREEZE'
DO message = messages-1 TO 0 BY -1 WHILE checked < todo
DROP email.
'MAILINFO STEM 'email.' INDEX 'message
IF SYMBOL('email.filename') ~= 'VAR' THEN DO
so = tls("Could not get information for message #") || message
SAY so
'REQUEST BODY "'smwrap(so,wrapat)'" "' || tls("_Ok") || '|' || tls("_Abort") || '"'
IF RESULT = 0 THEN DO
warncode = 5
LEAVE message
END
ELSE ITERATE message
END
/* testing mail for spam here. If spam, the "bad" flag is set to 1 (true) */
IF bad THEN DO
'MAILSETSTATUS FILENAME "'email.filename'" STATUS M'
IF moveit THEN DO
statpos = LASTPOS('.',email.filename)
IF statpos = (LENGTH(email.filename)-1) THEN spamFile = LEFT(email.filename,statpos-1) || '.8'
ELSE spamFile = email.filename || '.8'
'MAILMOVE FILENAME "' || spamFile || '" DESTFOLDER "'spamFolder'"'
END
zapped = zapped + 1
IF verbose THEN SAY '0a'x || tls("Spam message because ") || badrule
END
ELSE IF good THEN DO
IF verbose THEN SAY '0a'x || tls("Ham message because ") || goodrule
END
END
'MAILLISTTHAW'
-----
Let's say there are 5 mails to check (from index #4 to index #0).
Mail index #2 is a spam, it is marked as such and moved to the "Spam" folder.
Mails #1 and #0 cannot be checked because MAILINFO does not return anything anymore (eg.: email.filename is undef.)
(Another weird thing...)
I suspected that this problem could be due to the fact that MAILMOVE change the current folder to destfolder.
So, for testing, I've added the following two lines:
-----
'FOLDERINFO STEM 'testfold.
SAY testfold.name
-----
just after the MAILMOVE command.
Not only testfold.name proved that the current folder was still the right one (in the test: Incoming),
BUT ALL THE MAILS WERE PROCESSED TO THE END, the problem with MAILINFO not returning anything was gone ?!?
How can this be that FOLDERINFO "fixed" it ?