Using the Winsock (TCP/IP) ATEasy Driver Interface

Knowledge Base Article # Q200195

Read Prior Article Read Next Article
Summary This article contains a walkthrough of using the ATEASY WinSock interface to send/receive email messages as can be done using Telnet terminal.
Login to rate article

The following walkthrough demonstrates the creation and configuration of a WinSock interface based ATEasy® driver for sending/receiving TCP/IP messages to a remote server. Typically the Winsock interface is used to control LXI instruments however in this article you will be connecting to a mail server and sending email messages to the server following the SMTP protocol to send an email.

It should be noted that there are easier ways to send an email programmatically than by using Winsock.  This walkthrough is meant to demonstrate the use of ATEasy to perform the functions of a Telnet terminal automatically.  For a simplier way to send an email through ATEasy, please look into using the .NET framework's System.Net.Mail namespace to send emails (DotNet.prj example).  

This walkthrough mirrors a task that would normally be executed using a Telnet terminal (telnet.exe), as shown in the image below.  Using ATEasy, you are able to simplify and automate Telnet communication.

Using the ATEasy to create a WinSock interface, we can avoid having to use Telnet

Step by Step Walkthrough

1. Create a new ATEasy application
2. Create New Driver and name it EMAIL
3. Open the properties editor and examine the Driver properties for EMAIL.  Check the WinSock interface to enable it.

Screenshot: Enabling the WinSock interface for your EMAIL driver.

4. Click the Driver shortcut.  Change the interface to WinSock and configure it to the target mail server.  For this example, we will deliver the message through the domain GEOMAILSERVER on SMTP port 25.

Screenshot: The proper settings for contacting GEOMAILSERVER of the e-mail port 25

5. We must now create several IOTables to handle the communication between your computer and the mail server:

  • Create the Hello IOTable as shown below.  The Hello IOTable receives the server’s greeting message and initiates a dialog by introducing itself to the server.
Screenshot: The completed and commented Hello IOTable

  • Create the MailFrom IOTable as shown below.  The MailFrom IOTable sends the email address of the sender of the email to the server.  After receiving this, the server sends back an acknowledgement message.
Screenshot: The completed and commented MailFrom IOTable

  • Create the RcptTo IOTable as shown below.  The RcptTo IOTable sends the email address of the intended recipient of the email to the server.  After receiving this, the server sends back an acknowledgement.
Screenshot: The completed and commented RcptTo IOTable

  • Create the DataSend IOTable as shown below.  The DataSend IOTable informs the server that you are ready to transfer a message and sends the email subject, header and body.  Upon completion of transmission, the server sends back an acknowledgement that the message has been received and will be delivered.
Screenshot: The completed and commented DataSend IOTable

  • Create the Disconnect IOTable as shown below.  The Disconnect IOTable informs the server that you have finished and waits for the server to close the connection.
Screenshot: The completed and commented Disconnect IOTable

6. Once all the IOTables have been created, we want to create a procedure within the EMAIL driver to call all of our IOTables.  The procedure SendEmail is shown below.

Screenshot: The completed SendEmail procedure.

7.  The final modification to the EMAIL driver will be the creation of a command for use in the other modules of your ATEASY project.  Insert a new command, rename it to Send and attach it to the EmailSend procedure.

Screenshot: The Send() command.

Now that the driver is completed, we can use the Send() command in our Program module to send tests.  But we will need to open the Monitor window to observe the messages that are sent and received.  If it is not already open, hit the keyboard shortcut ALT+6 or use the menu bar View | Monitor to open it.  With the monitor window open, you are ready to send your email.  

The parameters of the command are (Sender, Recipient, Subject, Message) so a proper command could be:
Email Send("","","EMAIL Driver Test", "This message was sent courtesy of ATEasy!")

The ATEasy Monitor Window shows the messages that are being sent and received:

Screenshot: The monitor window after the email has been sent.

And, of course, the final product (Microsoft Outlook):

Screenshot: Received message from Outlook.
Article Date 5/19/2010 , 9/21/2021
Keywords Telnet, Winsock, LXI, SMTP, ethernet, communication, TCP/IP, client, server, email

Login to rate article

1 ratings | 4 out of 5
Read Prior Article Read Next Article