This example configures an MPTN connection and then transfers data from the host to a local file. The SetEncryptedString method is used here to specify the password. The data originates in MYLIB/PAYROLL(PAYROLL) on the host computer and is transferred to C:\Test\Payroll.txt on the PC. If a file of this name exists it is overwritten.

Sub AS400Transfer()

 With Session

  'Configure the connection

  .SetupSession rc5250Terminal, rc31792, rcMPTN

  .Hostname = "myhost"

  .UserName = "userid"

  .LocationName = "userid"

  .APPNNetID = "APPN1"

  .SetEncryptedString rcPassword, "mypass"


  'Transfer the file from the host to the PC

  .Xfr400RemoteFile = "mylib/payroll(payroll)"

  .Xfr400LocalFile = "C:\Test\payroll.txt"

  .Xfr400OutputDest = rcAS400File

  .Xfr400ExistsAction = rcOverwrite

  .PCSReceiveFile "", rcYes

 End With

End Sub