Attachmate Worldwide  |   Contact Us  |   The Attachmate Group
Extend. Manage. Secure. More than 30 years in the business. Over 65,000 customers.

Technical Notes

Automating Secure FTP (SFTP) Transfers Using the Reflection FTP Client API
Technical Note 1101
Last Reviewed 05-Mar-2014
Applies To
Reflection FTP Client version 14.0 or higher
Reflection for Secure IT Windows Client version 7.0 or higher

This technical note describes how to use the Reflection FTP Type Libraries, which provide a COM API to automate secure file transfers. Code samples in C# and VBA are provided.

Reflection FTP Client is included in many Attachmate products, including the following:

EXTRA! version 9.0 or higher
INFOConnect Enterprise Edition version 8.0 or higher
Reflection 2014
Reflection 2011
Reflection 2008
Reflection for HP
Reflection for IBM
Reflection for UNIX and OpenVMS
Reflection X

Note: For information about automating SFTP file transfers using Reflection for Secure IT command line utilities, see Technical Note 2126.

SFTP transfers can also be automated using a recorded script. For information about using an FTP Client script see Technical Note 1308.

Establish an Authentication Method that Can be Automated

To automate file transfers, Attachmate Technical Support recommends first setting up an authentication method that does not require user input, such as Public Key Authentication with an empty passphrase. It is possible to send a password in your program; however, the security risk is greater when plain text passwords are saved in source code.

For detailed steps on configuring Reflection for public key authentication, see Technical Note 1881.

Reflection FTP Type Libraries

Reflection FTP 1.15 Type Library (RFTPCOM15.DLL) is included with Reflection next generation emulation products—Reflection 2014 and Reflection 2011.

Reflection FTP 1.0 Type Library (RFTPCOM.DLL) is included with Reflection FTP Client 14.x, Reflection for Secure IT 7.x, EXTRA! 9.x, and INFOConnect Enterprise Edition 8.x.

To add a reference to Reflection FTP:

In a .NET project in Microsoft Visual Studio 2005 – 2010, go to Project > Add Reference.

Choose the COM tab and scroll to the FTP type library appropriate to your installation.

In Visual Basic for Applications, go to Tools > References.

Note: If you see both Reflection FTP 1.15 and 1.0 Type Libraries, you may have installed two incompatible versions of Attachmate products. One will need to be uninstalled before you can use the Reflection FTP API.

This example uses Reflection FTP 1.15 Type Library and works with Reflection 2014 and 2011. A variable is used to create a filter for file extensions. The application will transfer all files in a given directory that match the strFilter variable.

To see the .NET example:

  1. Download SFTP_ConsoleApp.cs.txt from the Attachmate Download Library.
  2. In Visual Studio, create a new C# console application.
  3. Replace all the code in Program.cs with the text of SFTP_ConsoleApp.cs.txt.
  4. Edit the code to put in the hostname and username of your SFTP server.
  5. Edit the following variables to fit your environment:

strHostPath, strLocalPath, strFilter, and strLogFile.

  1. Run or step into the code.

VBA Example

This example uses Reflection FTP 1.0 Type Library and works with Reflection FTP 14.x and Reflection for Secure IT. VBA is used to create a filter for file extensions. The macro will transfer all files in a given directory that match the strFilter variable.

  1. Download SecureFTP.bas, and import it to a VB or VBA editor.
  2. In your VB or VBA editor, add a reference to Reflection FTP 1.0 Type Library
  3. In the editor, click File > Import; then import SecureFTP.bas.

Using Reflection FTP Automation API, you can add features to your programs, such as checking to see if files exist before attempting a transfer, deleting files when you are done, writing error logs, or emailing system administrators when a critical file transfer fails.

Related Technical Notes
1308 Automating Reflection FTP Client File Transfers
1881 Configuring Reflection for Public Key Authentication
2126 Automating SFTP File Transfers with Reflection for Secure IT

horizontal line

Did this technical note answer your question?


Need further help? For technical support, please contact Support.