Subject: Well, yes I’ve done something similar
in my case, the database was a mail-in that accepted memos with attachments from external partners.
The agent I wrote processed each incoming memo
determined who had sent the file
mapped that to a directory
checked that no file of same name existed
if allowed detached the file into the correct directory
if not flagged it for manually processing
Therefore In my honest opinion its defintely possible to do what you want.
So how to do it?
My code is long gone, but I can give you some pointers
Once you have decided which directory you want to detach into you will need two things
a) a file name - I suggest you use the name of the attachment
b) a means of checking for teh presence of the file
and what you missed about DIR$ is in the middle of the help where you got your sample
“To determine whether a particular file exists, use an exact file name for the file_spec argument to Dir or Dir$. The return value is either the file name or, if the file does not exist, the empty string (”“).”
That means you can write a function something like this
(pointers only ; this code has not been compiled or tested)
REM Run this against a selected document that has Body field
Function DetachToDir( doc as NotesDocument, dirpath as string) as boolean
DetachToDir = False
If doc.HasEmbedded Then
Set body = doc.GetFirstItem("Body")
REM Get attachments
Forall att In body.EmbeddedObjects
If att.Type = EMBED_ATTACHMENT Then
filepath$ = dirpath & "\\" & att.Source
if dir$( filepath) then
Call att.ExtractFile(filepath$)
DetachToDirectory = True
end if
End If
end forall
end if
End Function
So now all you have to do is write the code to use it :=}
Note: if you want this to happen automatically - e.g. by a schedule agent - you need to ensure that he SERVER has access to the relevant directories
(In my case at first it was a drive on the same server
or later a mapped drive on a separate file server)
Good luck - and let us know how you get on