How can I use the MAIL_ADD_ATTACHMENT BIF in LANSA for the iSeries?

Date:18 August 2004
Product/Release:LANSA for the iSeries V9.1 and up
Abstract:MAIL_ADD_ATTACHMENT expects a path to a file in the IFS when used on the iSeries
Submitted By:LANSA Technical Support
Last Review:November 2010

Question:

What is the format of the Attachment Path when using the MAIL_ADD_ATTACHMENT Built-in Function in LANSA for the iSeries?

Answer:

MAIL_ADD_ATTACHMENT can only send files from the IFS. This is done by specifying the directory or file with a forward slash at the beginning.

Example 1: If there is a directory in IFS called 'Attach' and a file in that directory called 'dpcreate.log', you could attach the file to an email by using the format shown below.

USE BUILTIN(MAIL_ADD_ATTACHMENT) WITH_ARGS('/Attach/dpcreate.log' 'test.log') TO_GET(#LEM_RETC)

If you were to use a folder (say Reports), to send you attachments from there you would use the following structure.

USE BUILTIN(MAIL_ADD_ATTACHMENT) WITH_ARGS('/QDLS/Reports/dpcreate.log' 'test.log') TO_GET(#LEM_RETC

Example 2: You have a file SPOOLDTA residing in QTEMP and you want to copy it to a folder XXXX (which will become a subset of folder QDLS in the IFS) and attach this file to an email.

You will firstly need to copy the file SPOOLDTA to the IFS using command

EXEC_OS400 COMMAND('CPYTOPCD FROMFILE(QTEMP/SPOOLDTA) TOFLR(XXXX)')

Then you can use the following command to attach the file using MAIL_ADD_ATTACHMENT BIF

CHANGE FIELD(#KEYFILE) TO('''SPOOLDTA''')
USE BUILTIN(TCONCAT) WITH_ARGS('/QDLS/XXXX/' #KEYFILE) TO_GET(#FULLFILE)
* ********* Attach file to email
USE BUILTIN(MAIL_ADD_ATTACHMENT) WITH_ARGS(#FULLFILE #KEYFILE) TO_GET(#RETCODE)

* There are special considerations when calling the MAIL_ADD_ATTACHMENT BIF from LANSA Integrator.