Subject: RE: Notes FTP
Thanks for looking at that. Good idea…I simplified my code and re-ran it with no luck.
Here is my full code, it fails at the .ChangeDirectory FName:
On Error Goto Errhandler
Dim objFTP As NotesFTPSession
Dim session As NotesSession
Dim db As NotesDatabase
Dim fakedoc As NotesDocument
Dim ws As NotesUIWorkSpace
Dim item As NotesItem
Dim uidoc As notesuidocument
Dim doc As NotesDocument
Dim FType As String
Dim FName As String
Dim HasAccess As Variant
Dim GroupAccess As Variant
Dim SupportAccess As Variant
Set session = New NotesSession
Set ws = New NotesUIWorkSpace
Set db = session.CurrentDatabase
Set fakedoc = db.createdocument
Set objFTP=New NotesFTPSession
Set uidoc = ws.CurrentDocument
Set doc = uidoc.document
Set item = doc.GetFirstItem("FTPHistory")
'check to make sure the person can download these files
'anyone with designer or greater access and the requestor, FS and any added names in the FTPAccess field
HasAccess = Evaluate(|@IsMember(@Name([CN];@UserName);FieldSupervisor:Requestor:FTPAccess)|,doc)
'this code enables groups to be entered into the FTPAccess field
GroupAccess = Evaluate(|@ismember(FTPAccess;@usernameslist)|,doc)
SupportAccess = Evaluate(|@IsMember("[Support Group]";@UserRoles)|)
If HasAccess(0) = "1" Or GroupAccess(0) = "1" Or SupportAccess(0) = "1" Then
Else
Msgbox "You do not have sufficient access to download files from " & _
"this request. You must be the Requestor, Field Supervisor or listed in the Additional " & _
"Staff Needing Access field.", 0 +16, "process cancelled"
Exit Sub
End If
If Trim(doc.childRN(0)) = "" Then
Msgbox "There are no files to download", 0 +64, "process cancelled"
Exit Sub
End If
fakedoc.cxFilename = doc.cxfilename
fakedoc.cxFileType = doc.cxfiletype
fakedoc.PassWord = ""
fakedoc.LogonID = ""
fakedoc.PCfilepath = ""
If ws.dialogbox("DLB-FTPinfo",True,True,False,False,False,False,"FTP Input information",fakedoc,False) = False Then
Goto Cleanup
End If
With objFTP
.Connect myserver, fakedoc.LogOnID(0), fakedoc.PassWord(0), 0
For i = 0 To Ubound(fakedoc.cxfilechoose)
FType = Trim(Strright(fakedoc.cxfilechoose(i)," - "))
FName = Trim(Strleft(fakedoc.cxfilechoose(i)," - "))
' This will change to the root directory which needs to be because you come into the $XXXX directory
.ChangeDirectory " "
Print "...downloading " & FName & " .....please wait..."
.ChangeDirectory FName
If FType = "ASCII" Then
.GetFile |'| & FName & |'|, fakedoc.PCfilepath(0) & FName & ".CAG", FTP_TRANSFER_TYPE_ASCII
Else
.GetFile |'| & FName & |'|, fakedoc.PCfilepath(0) & FName & ".CAG", FTP_TRANSFER_TYPE_BINARY
End If
Next
.Disconnect
'create download history doc
Dim newdoc As NotesDocument
Set newdoc = db.CreateDocument
newdoc.form = "FTPHistory"
newdoc.FTPName = session.CommonUserName
newdoc.FTPfilepath = fakedoc.pcfilepath(0)
newdoc.FTPTime = Now
newdoc.ControlNumber = doc.ControlNumber(0)
Call newdoc.Save(True, False, True)
Messagebox "Your file(s) have been downloaded successfully to "& fakedoc.pcfilepath(0) & ". The support request will now be closed.", 0+48, "Process Complete"
' Call item.appendtotextlist(Cstr(Now) & " by " & session.CommonUserName & " to " & fakedoc.pcfilepath(0))
' Call doc.Save(True,False,False)
Call uidoc.Close
End With
Cleanup:
If Not (objFTP Is Nothing) Then
Delete objFTP
End If
Print " "
Exit Sub
ErrHandler:
Select Case Err
Case 302:
Msgbox "[Error #" & Cstr(Err) & "]: " & Error$ & " Check the $ ID and password you entered and re-try. If this problem persists, please contact Lotus Notes Support" & _
" for assistance.", 48, "NotesFTP Error"
Case 304 :
Msgbox "[Error #" & Cstr(Err) & "]: " & Error$ & " The filename(s) listed on this request may be incorrect, please contact the Assigned to (" & doc.Assignto(0) & _
") for assistance.", 48, "NotesFTP Error"
Case Else
Msgbox "[Error #" & Cstr(Err) & "]: " & Error$ ,48, "NotesFTP Error"
End Select
Resume Cleanup