*****************************************
      * CobolScript program name: email.cbl
      * This web-based program provides an example 
      * of SENDMAIL usage.
      *
      * Formatting characters in the TERXTAREA 
      * containing the message are translated 
      * by the web server to special codes; 
      * these are left as-is so that you can see
      * what the raw message looks like when you
      * receive the email.
      *
      * Copyright 2000 Deskware, Inc.
      *****************************************                                                            
      * Syntax: SENDMAIL USING     .               
      *
      * Include the TCP/IP variable copybook.
       COPY `tcpip.cpy`.

       1 web_header_html.
        5 `Content-type: text/html`.
        5 ` `.
        5 ``.
        5 `
`. 5 ` Sample Email Application
`. 5 `
This sample application demonstrates how to use CobolScript to send emails.

`. 1 email_form_html. 5 `



`. 5 `
`. 5 `

`. 5 ``. 5 ``. 5 ``. 5 ``. 5 ``. 5 ``. 5 ``. 5 ``. 5 ``. 5 ``. 5 ``. 5 ``. 5 ``. 5 ``. 5 ``. 5 ``. 5 ``. 5 `
To:
From:
Subject:
Message:
`. 5 `

`. 5 `  `. 5 ``. 5 `
`. 5 `
`. 1 web_footer_html. 5 `
`. 5 ``. main. 1 smtp_server PIC X(40). 1 content_length PIC 9999 VALUE 0. 1 error PIC 9. DISPLAYLF web_header_html. GETENV USING `CONTENT_LENGTH` content_length. IF content_length > 0 ACCEPT DATA FROM WEBPAGE PERFORM send_email END-IF. DISPLAY email_form_html. DISPLAY web_footer_html. GOBACK. send_email. * Change the value for smtp_server variable below to your own SMTP server. MOVE `yoursmtpserver.com` TO smtp_server. IF smtp_server(1:18) = `yoursmtpserver.com` DISPLAY `You must change the value for the smtp_server variable in the send_mail paragraph` & `
of this program to your own SMTP server before email can be sent.

` ELSIF to_address(1:5) = `Enter` OR to_address = SPACES OR from_address(1:5) = `Enter` OR from_address = SPACES DISPLAY `Enter a valid From: and To: email address
` ELSE SENDMAIL USING to_address from_address subject message smtp_server DISPLAY `

` DISPLAY `TCPIP-RETURN-CODE: ` & TCPIP-RETURN-CODE & `
` DISPLAY `TCPIP-RETURN-MESSAGE: ` & TCPIP-RETURN-MESSAGE & `
` END-IF.