There may be the need to process through local programs the incoming mail
for a given user. Examples could be:
- purge a distribution list by getting back non-delivery messages
- getting feedback messages in a marketing survey
- receiving orders by mail
- etc.
In concepts, such developments should be very easy, as all the tools
needed (database files, stream files, programming subprocedures) are already
available within AMailer.
To make it feasible, it takes a sample program that you may easily
understand and customize to your needs. Such a program is provided and is going
to be introduced in the next lines.
| |
The sample program and the command to call it are available in library MMAIL.
However, it must be understood that the customization of those two pieces
must not be done in library MMAIL. In order to preserve your work from installing
a future release of MMAIL, you should copy the source of the command
and the source of the program in a library of yours, and create
the command and the program in your library. |
The command is called PRCUSRMAIL and shows as follow:
|
| Figure 1 - Command PRCUSRMAIL |
This command processes the incoming mail for a given user.
Incoming mail for the given user is received. During the receiving phase
- Messages are saved as stream files
/amailer/xxx/nnn
- Message bodies are extracted and saved as stream files
/amailer/xxx/Bodies/nnn
- Message attachments are extracted and saved as stream files
/amailer/xxx/Attachments/nnn
where
- xxx is a 10 char string that stays for the username.
Relationships between usernames and such strings are found in file QGPL/AMUSERS.
- nnn is a 30 char string containing the same value as the name of the mother MIME stream file.
Meaning of command parameters:
- 'user ID' (parameter USERID)
Identifier of the user whose incoming mail must be
processed. Maximum length is 30 char. Case sensitive, use
quotes (').
The user must have already be defined to AMailer, see
Define users.
- Receive new mail (parameter RECEIVE)
Whether the latest incoming mail for this user should be
received now. One of the following:
- *NO - Do not receive the latest incoming mail for this user.
Just process the incoming mail for this user already received by
AMailer and not yet processed.
- *YES - Receive the latest incoming mail for this user. Then
process all the incoming mail of this user not yet processed.
- Purge after days (parameter PURGEDAYS)
Number of days since mail was processed, before it is
purged; or enter *NO to avoid mail purging.
- Display mail messages (parameter DSPMSG)
Whether the stream files of the new mail messages should be
displayed. Stream file display is performed via command DSPF (no
message editing performed) only if the command runs in interactive mode.
- Pgm to process mail messages (parameter PRCMSG)
You may specify the qualified name of an user program
intended to read and process each new mail message stream file.
This user program receives a single input parameter, char 512,
containing the path and the name of the mail message stream file.
- Display msg bodies (parameter DSPBDY)
Whether the bodies of the new mail messages should be
displayed. Stream file display is performed via command DSPF (no
body editing performed) only if the command runs in interactive mode.
- Pgm to process msg bodies (parameter PRCBDY)
You may specify the qualified name of an user program
intended to read and process the body of each new mail message.
This user program receives a single input parameter, char 512,
containing the path and the name of a message-body stream file.
- Display msg attachments (parameter DSPATC)
Whether the attachments of the new mail messages should be
displayed. Stream file display is performed via command DSPF (no
attachment editing performed) only if the command runs in interactive mode.
- Pgm to process msg attachments (parameter PRCATC)
You may specify the qualified name of an user program
intended to read and process each attachment of each new mail message.
This user program receives a single input parameter, char 512,
containing the path and the name of an attachment stream file.
This command invokes program PRCUSRMAIL
which does the following:
- Mark as deleted the messages to be purged (only if PURGEDAYS is other than *NO)
This is done in order to tell the POP server that these messages do not have to be retained any longer
at the POP server site. This type of cleanup is performed in the next step.
- Receive the new incoming messages addressed to this user (only if RECEIVE(*YES))
- Process all the messages that have not yet been processed
The process, to be locally customized, has control over the MIME file and the attachments of the message.
Access to database file AMMAIL (mail control records)
provides summary info about mail messages, such as
- name of the MIME stream file
- directory holding the message
- timestamp when sent
- sender's name and e-mail address
- main recipient's name and e-mail address
- subject
- Purge all processed and expired messages (only if PURGEDAYS is other than *NO)
- Extract and save as separate stream files the bodies and the attachments of the new messages received.
- Display and/or process through user programs
- the entire mail messages
- the message bodies
- the attachments of the messages
|