Hi Is there any possibility that agent checks users hard drive, get a file and and send an email with that file(attached in email).
Please suggest some key points.
Thanks in advance.
Hi Is there any possibility that agent checks users hard drive, get a file and and send an email with that file(attached in email).
Please suggest some key points.
Thanks in advance.
Subject: …and another…
You don’t mention - are you looking for a specific file in a specific location? Or do you have to search the entire drive for a specific file?
A solution to get directories and files in LotusScript
Posted by Sultan Yakalelo on 31.Jan.01 at 02:11 PM using a Web browser
Category: Domino Designer – LotusScriptRelease: All ReleasesPlatform: Windows NT
Below is one solution to get all directories and files from a specified location, something many developers seem to struggle around (see technote #172128, in which the workaround Lotus gave was not satisfying either because I was still getting the “Illegal function call” error).
More specifically, the function gets files and directories from one location and copies them into another location by using arrays and recursion. Hence, be careful, whereever there is recursion, there might be possible memory problems if too many recursive calls are made.
It saves all the content of a directory into an array and then loops through that array.
If it finds a directory when looping through the array, the function recursively calls itself (with the new parameters including the directory found);
Else copies the files into the appropriate directory.
Any comments/suggestions/questions/remarks welcome!
Sub gCopyMultipleFiles(Byval vstrFromPath As String, Byval vstrToPath As String)
Dim astrFileList() As String
Dim strDirOrFile As String
Dim intCount As Integer, i As Integer
intCount=0
strDirOrFile$ = Dir$(vstrFromPath & "", ATTR_DIRECTORY)
While (strDirOrFile$ <> “”)
If Not(strDirOrFile$ = “.” Or strDirOrFile$ = “…”) Then ’ Do not save . and … directories (current and parent directories)
Redim Preserve astrFileList(intCount)
astrFileList(intCount) = strDirOrFile$
intCount = intCount + 1
End If
strDirOrFile$=Dir$()
Wend
If Not(gintDirectoryExists(vstrToPath & "")) Then ’ If it is a new directory, create it
Mkdir vstrToPath
End If
For i = 0 To intCount-1
strDirOrFile$ = astrFileList(i)
If gintDirectoryExists(vstrFromPath & "" & strDirOrFile$ & "") Then
’ We have a sub-directory, go into that sub-directory by calling gCopyMultipleFiles with parameters including the new directory
gCopyMultipleFiles vstrFromPath & "" & strDirOrFile$, vstrToPath & "" & strDirOrFile$
Else
’ We have a file, copy it into current directory
gCopyFile vstrFromPath & "" & strDirOrFile$, vstrToPath & "" & strDirOrFile$, True
End If
Next
End Sub
Sub gCopyFile(Byval vstrFromFilePath As String, Byval vstrToFilePath As String)
’ Copies a file from one location to the other. For additional security, you can check if the source file exists
’ at the source and destination, if you can overwrite it etc.
On Error Resume Next
Filecopy vstrFromFilePath, vstrToFilePath ’ Copy the source to the destination, the calling routine should handle error
If Err Then
Error Err, strErrorPrefix & Cstr(Error)
Exit Sub
End If
On Error Goto 0
End Sub
Public Function gintDirectoryExists(Byval vstrDirectoryPath) As Integer
’ Checks whether a directory exists, returns true or false
Dim strDirectoryFound As String
gintDirectoryExists=False
On Error Resume Next
strDirectoryFound = Dir$(vstrDirectoryPath, ATTR_DIRECTORY)
If Err Then
Err=0
Exit Function
End If
On Error Goto 0
If strDirectoryFound <> “” Then
gintDirectoryExists=True
End If
End Function
Subject: agent that finds file on the users hard drive and send an email
Yes - almost anything is possible with Notes/Domino
There are plenty of samples of sending emails in the forums, so if you’re not familiar with sending email a quick search should get you going.
Searching folders recursively can also be done, I did some work on this years ago, but do not have that with me. I started with some information i found in this thread:
with this search:
www-10.lotus.com/ldd/nd6forum.nsf/Search?SearchView&Query=recursive dir%24
Subject: Here’s another
Here’s another thing that i found way back then that helped me:
RE: Dir$ useless for recursive access to sub-directories
Posted by Gil Braun on 7.Jul.98 at 07:01 PM using a Web browser
Category: Notes Designer – LotusScriptRelease: Platform:
This is working code that we use in a source code project manager database (it imports files from a dir and its recursive subdirs, as attachments into Notes docs describing each file), it contains what you want.
Option Public
Option Declare
Dim basePath As String
Sub GetProjectFiles(inDir As String, category As String)
Dim searchSpec As String
Dim dirName As String
Dim dirList() As String
Dim dirCount As Integer
Dim fileName As String
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim rtItem As NotesRichTextItem
Dim view As NotesView
Dim dt As NotesDateTime
Dim key(1 To 2 ) As String
Dim stripCount As Integer
Dim partialPath As String
Set db = session.CurrentDatabase
Set view = db.GetView(“Project Details”)
Chdir(inDir)
inDir = Curdir()
If basePath = “” Then basePath = inDir
stripCount = Len(basePath)
partialPath = Mid (inDir,stripCount + 1)
key(1) = category
key(2) = partialPath
Set doc = view.GetDocumentByKey(key,True)
If doc Is Nothing Then
If Len(partialPath) > 0 Then
Set doc = db.CreateDocument
doc.Form=“Project”
doc.FileDateAndTime = “Directory”
doc.Category = category
doc.DocType = “Directory”
doc.ItemText = partialPath
Call doc.Save(True, True)
End If
End If
’ Trap PATH NOT FOUND errors.
On Error 76 Resume Next
dirCount = 0
If Right(inDir,1) <> "" Then
searchSpec = inDir & “*.*”
Else
searchSpec = inDir & “.”
End If
dirName = Dir(searchSpec, 16)
Do While dirName <> “”
If dirName <> “.” And dirName <> “…” Then Chdir (dirName)
If Curdir <> inDir Then
Chdir(“…”)
Redim Preserve dirList (dirCount)
dirList (dirCount) = dirName
dirCount = dirCount + 1
End If
dirName = Dir
Loop
’ Now do the search for files
’ getfiles
Call GetFiles(category, db, view, “*.htm”, partialPath)
Call GetFiles(category, db, view, “*.gif”, partialPath)
Call GetFiles(category, db, view, “*.jpg”, partialPath)
Forall s In dirList
Call GetProjectFiles(s, category)
End Forall
Chdir (“…”)
End Sub
Sub GetFiles(category As String, db As NotesDatabase, view As NotesView, spec As String, partialPath As String)
Dim doc As NotesDocument
Dim fileName As String
Dim key(1 To 2 ) As String
Dim hasChanged As Integer
Dim rtItem As NotesRichTextItem
fileName = Dir(spec, 15)
While fileName <> “”
hasChanged = True
key(1) = category
key(2) = partialPath & "" & fileName
Set doc = view.GetDocumentByKey(key,True)
If Not doc Is Nothing Then
If doc.FILEDATEANDTIME(0) = Filedatetime(Curdir & "" & fileName) Then
hasChanged = False
Print "Skipping " & Curdir & "" & fileName
Else
Call doc.Remove(True)
Msgbox Curdir & “" & fileName & " has changed”
End If
End If
If hasChanged Then
Print "Importing " & Curdir & "" & fileName
Set doc = db.CreateDocument
doc.Form=“Project”
doc.Category = category
doc.DocType = “File”
doc.ItemText = partialPath & "" & fileName
Set rtitem = New NotesRichTextItem( doc, “Attachment”)
Call rtitem.EmbedObject(EMBED_ATTACHMENT, “”, Curdir & "" & fileName)
doc.FileDateAndTime= Filedatetime(Curdir & "" & fileName)
Call doc.Save(True, True)
End If
fileName = Dir
Wend
End Sub
Sub Initialize
basePath = “”
End Sub
This topic was automatically closed 8 hours after the last reply. New replies are no longer allowed.