Sending data through FTP
Many external applications still accept files and submissions through FTP. Windows has a built-in FTP client that we can leverage to perform this type of transmission.
Getting ready
You will need a working FTP server and valid logon credentials in order to run this recipe.
How to do it...
Create a new codeunit from Object Designer.
Add a function named
FTP
that takes in the following parameters:Name
DataType
Length
UserName
Text
50
Password
Text
50
ServerName
Text
50
FileToMove
Text
255
Add the following local variables to the function:
Name
DataType
Length
BatchFileName
Text
250
BatchFile
File
BatchFileStream
OutStream
BatchFileData
Text
250
Add the following code to the function:
BatchFileData := 'c:\navFTP.dat'; BatchFileName := 'c:\navFTP.bat'; BatchFile.CREATE(BatchFileName); BatchFile.CREATEOUTSTREAM(BatchFileStream); BatchFileStream.WRITETEXT('@echo off'); BatchFileStream.WRITETEXT; BatchFileStream.WRITETEXT('echo user ' + UserName...