yam
yam copied to clipboard
ARexx - MAILIMPORT / MAILEXPORT : return FILENAME
Originally by [email protected] on 2010-03-04 22:40:41 +0100
This feature has already been partially discussed, but the issue is still a blocker problem for me: I can't operate on freshly imported mails because I found no way to identify those mails.
My suggestion is to allow the MAILIMPORT to return:
- the INDEX of the last imported mail,
- VAR/K as alternative variable for result,
- <STEM>COUNT : number of imported mails <STEM>NR : the INDEX of the imported mail where NR is a value between 0 and COUNT-1
The same extension could be implemented to MAILEXPORT as well, as it can help, for example, to delete or change status of exported mails.
Originally by amigaphil on 2010-03-04 22:42:00 +0100
In the meantime, I found a workaround so that the 'preserve mail status of imported mails' will work even with YAM 2.5. In the 'import' folder (made the current one for the process), all the mails are read with MAILINFO, and each MSGID in kept in a stem. After each MAILIMPORT, all the mails are checked again to find which MSGID is (are) newer. Then, the newer (imported) mail is made current, and its status can be restored with MAILSTATUS.
Not very nice as a solution, as it involves many loops (so slower in ARexx), but it works with the current stable and dev version of YAM. So the feature requested is still welcome, but I lowered the priority level to 4.
Originally by amigaphil on 2010-03-04 22:43:05 +0100
(Sorry to ask a question here, but I got no reply to my subscription request for the user list.)
The "workaround" I explained in my previous comment (checking all MSGID to find the newer one) is barely acceptable when importing only a few mails, but is a PITA when importing hundreds mails (the script run almost exponentially slower, depending of the sort order of the mails in the import folder).
Another approach which sounds way much better is :
- NEWMAILFILE to get the futur filename of a new mail,
- MAILIMPORT to import one mail,
- SETMAILFILE to make the imported mail the current one,
- MAILSTATUS to change the status of that mail.
Now the question is: Is it safe ? Can I rely that the filename returned by NEWMAILFILE will for sure be the one of the imported mail ? (If so, it will solve the problem I'm faced with and I'll close/delete this feature request.)
Originally by amigaphil on 2010-03-04 22:43:44 +0100
Can I rely that the filename returned by NEWMAILFILE will for sure be the one of the imported mail ?
That looked too good to be true :-( The filename of the imported mail is NOT the filename returned by NEWMAILFILE.
Back to first step, the feature requested for MAILIMPORT / MAILEXPORT still is the most convenient solution (those commands could return the filename instead of the index if it is easier to implement).
Alternatively, a new command like SimpleMail's MAILADD would help as well.
Originally by amigaphil on 2010-03-04 22:44:22 +0100
Yet another method, so far the best one:
Instead of exporting first the mails in a temp. mbox file before importing them in YAM with MAILIMPORT, the mails are now written straight in the destination folder, with a filename given by NEWMAILFILE. The status of the mails are restored/changed by modifying the filename extension (,R ,N). After all the mails are imported, the script do a MAILUPDATE to re-build the folder index.
This method is the fastest one. No need to deal with LISTSELECT or SETMAIL to change the status of the imported mails. The script will work under YAM 2.5 and YAM 2.6. The only inconvenient is that after a MAILUPDATE, the N (new) status a mail might have is lost (I'll post a request about this for 2.6). Also, if the filename structure change again in the future, the script might not work anymore.
(As the issue of 'preserving the status of imported mails' is now almost solved, I lower the priority of this request to 2.)
Originally by amigaphil on 2010-03-04 22:46:01 +0100
Re-considering this again. But instead of returning INDEX, it would be even more useful if MAILIMPORT could return a list of FILENAMEs (as returned by NEWMAILFILE).
stem.FILENAME.COUNT
stem.FILENAME.0
...
stem.FILENAME.NR
So that those filenames could be used with MAILSTATUS (to be extended as well to use a FILENAME argument) to change/restore the status of the imported mails.
(See Support request #2912954 - "Import" Arexx scripts - testing request https://sourceforge.net/tracker/?func=detail&aid=2912954&group_id=13560&atid=213560)
Originally by amigaphil on 2010-03-04 22:47:15 +0100
(Just change the title of this artifact to reflect my last posted comment.)
Instead of returning INDEX, it would be even more useful if MAILIMPORT could return a list of FILENAMEs (as returned by NEWMAILFILE). stem.FILENAME.COUNT stem.FILENAME.0 ... stem.FILENAME.NR
(Related: FILENAME as input argument for MAILSTATUS https://sourceforge.net/tracker/?func=detail&aid=2928409&group_id=13560&atid=363560)