****************************************
      * Program name: mail.cbl
      * This program provides several examples
      * of email statement usage.
      *
      * Copyright 2000 Deskware, Inc.
      ****************************************                                                                                                        
      *                                                               
      * Include the TCP/IP variable copybook.
       COPY `tcpip.cpy`.
       
      * Program Variables
       1 to_address      PIC X(30).
       1 from_address    PIC X(30).
       1 subject         PIC X(40).
       1 message.
          5 message_text1   PIC X(100).

       1 email_address   PIC X(30).
       1 email_password  PIC X(30).
       1 email_count     PIC 9(05).
       1 email_number    PIC 9(05).
       1 email_filename PIC X(20).
       1 smtp_server PIC X(40).
       1 pop3_server PIC X(40).
       1 num_attachments PIC 9999.
       1 attachment_names.
         5 attachment1     pic x(20).
         5 attachment2     pic x(20).
         5 attachment3     pic x(20).
       1 mail_to           pic x(30).
       1 mail_from         pic x(30).
       1 mail_reply_to     pic x(30).
       1 mail_cc           pic x(30).
       1 mail_date          pic x(30).
       1 mail_subject      pic x(30).
       1 mail_organization pic x(30).



      * Substitute your information in for the literals below  
       MOVE `yourmail@yourdomain.com` TO email_address.
       MOVE `test`           TO email_password.
       MOVE 1                    TO email_count.
       MOVE `yourpop3.com` TO pop3_server.

       GETMAILCOUNT USING email_address
                          email_password
                          email_count
                          pop3_server.
      
       DISPLAY `email_count: `  & email_count.
       DISPLAY `TCPIP-RETURN-CODES: `  & TCPIP-RETURN-CODES.
      
       MOVE `youremail@yourdomain.com` TO email_address.
       MOVE `test` TO email_password.
       MOVE 1 TO email_number.
       MOVE `mymail.txt` TO email_filename.
       MOVE `yourpop3` TO pop3_server.
       GETMAIL USING email_address
                     email_password
                     email_number
                     email_filename
                     pop3_server
                     `N`
                     `c:\`
                     `num_attachments`
                     `attachment_names`
                     `mail_to`
                     `mail_from`
                     `mail_reply_to`
                     `mail_cc`
                     `mail_date`
                     `mail_subject`
                     `mail_organization`
                     `n`.



       display `CS return values from GETMAIL:`.
       display `num_attachments: ` & num_attachments.
       displaylf `attachment_names: ` & attachment_names.
       display `mail_to:` & mail_to.
       display `mail_from:` & mail_from.
       display `mail_reply_to:` & mail_reply_to.
       display `mail_cc:` & mail_cc.
       display `mail_date:` & mail_date.
       display `mail_subject:` & mail_subject.
       display `mail_organization:` & mail_organization.



       DISPLAY `TCPIP-RETURN-CODES: `  & TCPIP-RETURN-CODES.
       GOBACK.