Mail - Service Program



Based on source printed in News/400 article autumn 1998.

A very interesting article, but to be make the program more useful I've changed it into a service program. I've also expanded the message parameter so that very long messages can be sent. I use these routines in programs that mail short reports built programmatically as an alternative to 'print & fax'.

The service program could be improved by adding the option of supplying more than one message recipient for each 'MailSend' and by allowing more than one attachment file, but what can you expect from free AS/400 software?

Sample code for use of this service program:

callp	MailFile ('/etc/tmp' + %trim(user) + '_' +
	%trim (%editc (MailSeq : '3')) + '.txt'
callp	MailFrom ('njal.fisketjon@broadpark.no' : 'Njål Fisketjøn')
callp   MailTo ('as400user@world.com' : 'AS/400 user')
callp	MailSubject ('Free service program for your AS/400')
callp	MailMessage ('Hope this software is useful to you.')
eval	*in99 = MailSend

Note!: Using the MailFile procedure to set the temporary file name is not required if you're sending only one message 'at the time'

Prototype sources:

Mail routines source

Note!: You will have to replace the 2 xlate statements in the MailSend routine with eval if you use a character set (code page) where the @ character has the same ebcdic code as in the U.S.A. The eval statements should assign the factor 2 fields to the result fields.

Service Program binder source
22nd November 1999