Skip to content


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:\Users\Administrator\Downloads\ftp\README.txt”
Const remoteFile As String = “/README.txt”
Const host As String = “”
Const username As String = “anonymous”
Const password As String = “”

‘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 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


Tech Tuesday: Building My First Matrix Report
Overcoming the Top Challenges of Zendesk Integration
Accessing Historical Dynamics GP Data in NetSuite: Using Popdock
Popdock's Top 10 New Features
New Webinar: Getting Started with Matrix Reporting in Popdock


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



Business Central CRM D365 Business Central Dynamics 365 dynamics crm Dynamics GP Dynamics NAV Econnect Employee Spotlight eone eOne News error Error Message Events Excel Excel Report Builder Extender Flexicoder GP integration Map Microsoft dynamics crm Microsoft Dynamics GP Navigation List Builder Office Relationships Partner All Hands Call Popdock promotions release SalesForce SmartConnect SmartConnect Bootcamp SmartConnect Maps SmartConnect Office Hours SmartList SmartList Builder SmartPost SmartView SQL Tech Tuesday Templates training Zendesk

Integrate & Automate without Any Code.

SmartList Data has Never Been Faster.

The Easiest Way to Report on GP Data.