****************************************************************** *** MAIL API FOR GUI-SCREENIO *** *** *** *** This api sends mail (does not receive) and is designed *** *** to be called from your program with the fields below *** *** filled in. It's not guarenteed to work with anything *** *** other than smpt servers that are compliant with internet *** *** standard RFC 2821. http://rfc.sunsite.dk/rfc/rfc2821.html *** *** *** *** Included in the sent Email will be all the normal headers *** *** and in addition, the USER-AGENT: header will specifying *** *** your GUI-ScreenIO serial number. NORCOM does not want *** *** to receive spam reports related to the use of this *** *** software. *** *** *** * : As of 1/2007 this API supports * : authentication. ****************************************************************** * To use: * * COPY WIN32API. * COPY MAILAPI. * . * . * . * ------------------------: Load the data specifying the body: * : Note the sample text below is not * : complete and serves as only one * : possible way of loading the body * : text, the important point being * : the need for you to place carriage * : return line feed pairs in the text * : to format the message. * : * : Note that a GUI-ScreenIO multiline * : text control will automatically * : insert CRLF in the text if you select * : the "Enter key starts new line * : of text" option. Therefore you can * : take the output of a Multiline edit * : control and move it directly into your * : email message. * MOVE 'Joe Smith ' TO APM-YOUR-NAME * MOVE 'Joe Smith ' TO APM-YOUR-NAME * MOVE 'JoeSmith@joe.com ' TO APM-YOUR-EMAIL * MOVE 'smtp.joe.com' TO APM-SMTP-SERVER * MOVE 25 TO APM-PORT * MOVE 'smtp.joe.com' TO APM-SMTP-SERVER * MOVE 'A message from Joe' TO APM-SUBJECT * . * . * MOVE ZERO TO WS-TXT-POINTER * : For each line in our message source * : (in this example code this is in * : an array called msg-line which occurs * : msgmax times... * PERFORM VARYING MSGLN FROM 1 BY 1 * UNTIL MSGLN > MSGMAX * OR WS-TXT-POINTER > LENGTH OF APM-TEXT * : This moves each line of the message * : into the mail message and appends * : a carriage return line feed... * : Note that a line is limited to 1000 * : characters by rfc2821, and if you * : violate this limit your mail will * : have truncated paragraphs. This is * : common with braindead Microsoft email * : packages. * STRING MSG-LINE (MSGLN) X'0D0A' * DELIMITED SIZE INTO APM-TEXT * WITH POINTER WS-TXT-POINTER * END-PERFORM * * * ------------------------: Call the API to SEND the MAIL. * * SET FUNC-SENDMAIL TO TRUE. * CALL 'GSWINAPI' USING WIN32API-PARMS * APM-MAIL-PARMS * WIN32API-B * WIN32API-C * WIN32API-D * WIN32API-E * WIN32API-F. * * ------------------------: If function failed, * : display a textual error message. * * IF WIN32API-FAILED * MOVE WIN32API-ERROR-TEXT TO my-error-message * do whatever to display my-error-message. * ****************************************************************** 01 APM-MAIL-PARMS. * : Your name, in Plain text. 05 APM-YOUR-NAME PIC X(50) VALUE SPACE. * * : Your return email address: * : Form: yourmame@yourdomain.com 05 APM-YOUR-EMAIL PIC X(0250) VALUE SPACE. * * : The name or IP of your SMTP server * : Not case sensitive. * : Forms: smtp.yourisp.net * : 127.0.0.1 05 APM-SMTP-SERVER PIC X(0250) VALUE SPACE. * * : The port the smtp server listens on * : typically 25 but may vary. 05 APM-PORT PIC 9(4) VALUE 25. * * : Text name of recipient * : Person Name = Clear text persons * : name. * : Example: John T. Doe 05 APM-TO-NAME PIC X(0250) VALUE SPACE. * * : Email address the mail should be sent * : to, single address only. * : Example: jdoe@hisisp.com 05 APM-TO-EMAIL PIC X(0250) VALUE SPACE. * * : Subject line of the email in clear txt 05 APM-SUBJECT PIC X(0200) VALUE SPACE. * * : Message body. Trailing spaces will be * : dropped. May (should) include line * : breaks at desired places by stringing * : in standard carriage return line feed * : pairs. ( X'0D0A' which we provide * : above for ease of use). Body lines * : longer than 1000 characters will be * : split to conform to internet standards 05 APM-TEXT PIC X(20000) VALUE SPACE. * : Some form of authentication is a ever * : more frequent requirement and you are * : encouraged to provide for this in your * : application to avoid obsolecense. 05 APM-AUTHENTICATION VALUE SPACE. * : One byte Flag which must be Y if you * : want the this API to attempt to * : authenticate to the smpt server. * : As of this writing the API undestatnds * : authentication methods "PLAIN" and * : "LOGIN". More will be added as needed * : and the method selected will be the * : highest the smtp server honors. * : 10 APM-AUTHENTICATION-SWITCH PIC X. 88 APM-AUTHENTICATE-DESIRED VALUE 'Y'. * : Your user name and password at the * : smtp server. (case sensitive) * : * : You must provide a method for your * : end-users to supply this information. * : * : Typically the userid is your * : email login (the part of your email * : address preceeding the @ sign). 10 APM-AUTHENTICATION-USERID PIC X(50). * : This is typically the same as your * : email password. 10 APM-AUTHENTICATION-PASSWORD PIC X(50).