Hi
I’ve got an agent the runs down a view with dozens of documents, each of which have a file attachment which I need to dump to disk.
Each time the agent runs, a random set of files gets extracted!!
I’ve stepped through with the debugger and every file gets extracted, but right after the extract statement, the files don’t always appear in the directory!!
I’ve tried extracting in batches of 5, and only 4 usually get dumped out, and it’s random which of 4 are extracted from the sets of 5 (i.e sometimes first one is missing, or last or a middle one).
Any suggestions?
TIA
Mohib
Subject: RE: Help!! ExtractFile randomly doesn’t work - suggestions?
It’s a matter of timing. ExtractFile happens in the background, sort of, at least on some OS.
You should use the file functions of LotusScript to repeatedly check whether the file is there and of non-zero size. I think that will be enough to make sure it’s all there.
Subject: RE: Help!! ExtractFile randomly doesn’t work - suggestions?
Thanks, that’s right – but it’s very strange.
The issue is not to put a delay in the loop doing the extracts between each extract (the obvious place you’d think), but to do the extracts in batches (I do 15 at ago) and then put a delay before the first file in each batch is done. Specifically it seems you can put just one delay right after you do NotesView.GetFirstDocument (which is really before even the first batch starts) or before NotesViewEntryCollection.GetFirstEntry, but I put them before each batch to be safe.
I use Sleep(1), so I delay 1 second between each batch. Putting a sleep(1) after every extract would really slow everything down, and doesn’t seem to be needed.
Seems like Notes needs some time to get set after doing GetFirstDocument or GetFirstEntry before it can do an extract, even though the NotesRichTextNavigator has found the attachment and you’re able to do the extract method without an error.