Tech Tuesday: Creating a Task in SmartConnect to get a file from an FTP site

This weeks Tech Tuesday is from our very own Chris Dew, our Director of Product Management, who will explain how to create a task in SmartConnect to get a file from an FTP site.

We get quite a few customers that want to take files from a FTP site and utilize this file as the source of their data when running a map inside of SmartConnect. Today I have created a sample Task script that will allow you to grab a file in a Pre Map Task and then use it for the integration.

First you can simply click on the Tasks button in any existing map, and then choose a new task called run script. This is where you can now copy the script below and paste into this window (like in the image below).



        Const localFile As String = “C:UsersAdministratorDownloadsftpREADME.txt”
        Const remoteFile As String = “/README.txt”
        Const host As String = “ftp://ftp.swfwmd.state.fl.us/pub/”
        Const username As String = “anonymous”
        Const password As String = “email@email.com”

        ‘Create a request
        Dim URI As String = host & remoteFile
        Dim ftp As System.Net.FtpWebRequest = CType(System.Net.FtpWebRequest.Create(URI), System.Net.FtpWebRequest)
        ‘Set the credentials
        ftp.Credentials = New System.Net.NetworkCredential(username, password)
        ‘Turn off KeepAlive (will close connection on completion)
        ftp.KeepAlive = False
        ‘we want a binary
        ftp.UseBinary = True
        ‘Define the action required (in this case, download a file)
        ftp.Method = System.Net.WebRequestMethods.Ftp.DownloadFile

        ‘If we were using a method that uploads data e.g. UploadFile
        ‘we would open the ftp.GetRequestStream here an send the data

        ‘Get the response to the Ftp request and the associated stream
        Using response As System.Net.FtpWebResponse = CType(ftp.GetResponse, System.Net.FtpWebResponse)
            Using responseStream As IO.Stream = response.GetResponseStream
                ‘loop to read & write to file
                Using fs As New IO.FileStream(localFile, IO.FileMode.Create)
                    Dim buffer(2047) As Byte
                    Dim read As Integer = 0
                        read = responseStream.Read(buffer, 0, buffer.Length)
                        fs.Write(buffer, 0, read)
                    Loop Until read = 0 ‘see Note(1)
                End Using
            End Using
        End Using
return true

The only configuration that needs to be done is at the very top where you determine four things:
1) The name and location you want to put the file on your network
2) The name of the remote file
3) FTP Site
4) Username
5) Password

Have fun with this one and use your imagination on other scripts you can use. If you have a suggestion for a new script please let me know.


Chris Dew

Interested in SmartConnect? Please email us at sales@eonesolutions.com and we would be happy to assist you!

1 Comment

  1. RLMcVicar on July 11, 2014 at 2:40 pm

    When can we start seeing the SmartView and SmartList Builder in a web Client in or outside of Dynamics GP?

Leave a Comment


2020 Q3 Promotions
Last Chance! Dynamics GP Integration Bootcamp in July 2020!
Happy Fourth of July from eOne Solutions!
Throwback Thursday: Microsoft CSP Billing Integration Case Study
Throwback Thursday: Tips, Tricks & Gotcha Moments when Connecting


2016 SmartConnect Integration Bootcamps
Tech Tues: Automatically refreshing Pivot Tables in Excel Refreshable Reports
Happy Thanksgiving from the eOne team!
New Releases of Extender and SmartList Builder
2017 SmartConnect Integration Bootcamps



open all | close all


Business Central CRM Dynamics 365 dynamics crm Dynamics GP Dynamics NAV Econnect Employee Spotlight eone eOne News Events Excel Excel Report Builder Extender Extender Enterprise Flexicoder GP GPUG integration Meet the Team Microsoft dynamics crm Microsoft Dynamics GP Office Relationships partners Popdock promotions release Reporting SalesForce SalesForce.com scripting SmartConnect SmartConnect.com SmartConnect Bootcamp SmartConnect Office Hours SmartList SmartList Builder SmartList Designer SmartView SQL Support Tech Tuesday Templates training Zendesk

Integrate & Automate without Any Code.

SmartList Data has Never Been Faster.

The Easiest Way to Report on GP Data.