OPALE - 10.0 - Usage - E-mailing a PDF file
MAPSNDMAIL
Sommaire
Introduction
Thanks to Opale and the MAPSNDMAIL command, you can now send e-mails that have PDF documents attached to them and a customised HTML body.
The MAPSNDMAIL command uses a Designer template ("Mapping format" parameter) to build the e-mail around it. The template has to be generated in PDF. It has to include INDEX type zones used as dynamic data in the subject, naming of the attachments or in the body of the e-mail.
General principles of the MAPSNDMAIL command
The MAPSNDMAIL command on IBM i uses multiple parameters:
Spooled file . . . . . . . . . . Name Spooled file name Spooled file number . . . . . . *LAST *LAST *ONLY 000000-999999 Spooled file number Job Name . . . . . . . . . . . . *CURRENT Name, *CURRENT , *DEV Job name Job number . . . . . . . . . . . 000000-999999 Job number User . . . . . . . . . . . . . . *CURRENT Name User Mapping format . . . . . . . . . Character value,10 max. Designer Format Sequence . . . . . . . . . . . . *ALL *MRG 00000-99999 Designer project sequence number Delete file . . . . . . . . . . N Y, N Delete the original spooled file? Start page . . . . . . . . . . . 1 Integer, *SPL Starting page number End page . . . . . . . . . . . . 999999 Integer, *SPL, *LAST Ending page number Original State . . . . . . . . . 'READY' HOLD, READY Email status? PRIORITY . . . . . . . . . . . . '3' 1, 2, 3, 4, 5 Sending priority Send from . . . . . . . . . . . *USER Email sender Send TO . . . . . . . . . . . . _______________________________________________ Email recipient Send CC . . . . . . . . . . . . _______________________________________________ Carbon Copie(s) Send CCI . . . . . . . . . . . . _______________________________________________ Blind Carbon Copie(s) Subject . . . . . . . . . . . . _______________________________________________ Email subject Note . . . . . . . . . . . . . . _______________________________________________ Email body Name of this file in the mail . 'Doc.pdf' Name of the PDF file sent via email Path and name of the file . . . ________________________________________________ Path of a potential additional attachment Name of this file in the mail . ________________________________________________ Name of a potential additional attachment Delete mail after send . . . . . 'N' Y, N, O Delete the email after it was send Delete file1 after send . . . . 'N' Y, N, O Delete the first attachment Delete file2 after send . . . . 'N' Y, N, O Delete the second attachment Other parameters Code Page . . . . . . . . . . . *SPL *SPL, 037,1147 Specify a code page
The menu that allows you to send e-mails is called MAPSND. To access it, run command:
GO MAPSND
1. E-mail configuration
This screen is only accessible if you have been granted SECOFR rights.
SMTP server IP address Name of the SMTP server SMTP server port (25) Connection port number SMTP server domain SMTP server domain name Temporary folder Temporary folder (MAPSEND folder by default) The temporary folder is where PDF files that where sent via e-mail are stored, users who send e-mails need access to read and modify this folder. Waiting Dtaq ***detail to be completed*** by default: MAPSMTP MAPSMTP is the default DTAQ (created upon installation), it allows the Mapping robot to send the spooled files automatically to the e-mail server. This DTAQ needs to exist. Sending jobd ***detail to be completed*** by default: MAPDSMTP2 MAPDSMTP2 is the default JOBD (created upon installation). It defines the properties of the robot's e-mail sending jobs. This JOBD needs to exist. Action if success ***detail to be completed*** *USER Three possible values: - *NONE. By default, no command is run. - *USER. By default, the SNDUSRMSG TOUSR(&USER) command is run. - *SYSOPR. By default, the SNDUSRMSG TOUSR(*SYSOPR) command is run. Action if error ***detail to be completed*** *USER Success and error reactions are managed in the MAP_C031P9 program. Sources of this program can be found in the MAP_SPECIF file of the installation library. Three possible values: - *NONE. By default, no command is run. - *USER. By default, the SNDUSRMSG TOUSR(&USER) command is run. - *SYSOPR. By default, the SNDUSRMSG TOUSR(*SYSOPR) command is run.
2. Starting e-mail management
This menu allows you to start the MAPSMTP job of the sub-system. To send e-mails via the MAPSNDMAIL command, this job needs to be started. This menu calls the STRMAPMAIL command.
3. Stop mail
This menu allows you to stop the MAPSMTP job of the sub-system. This menu calls the ENDMAPMAIL command.
4. Displaying e-mail queue
This menu allows you to display the previously sent e-mails, which you can filtrer by user name. This menu calls the MAPDSPMAIL command.
Caution: This menu stops you from sending new e-mails so do not leave it open.
5. Sending an e-mail
This menu allows you to send an e-mail with (or without) an attachment. This menu calls the MAPSNDDST command.
6. Sending a spooled file via e-mail
Ce menu allows you to map an IBM i spooled file as well as its PDF version and its e-mail version. This menu calls the MAPSNDMAIL command.
7. Contrôle du fonctionnement du mail
This menu allows you to list the jobs of the sub-system that are linked to e-mail sending (MAPSMTP in this case).
8. Managing spooled files (MAPPING interactive run)
This menu allows you to manage spooled files. This feature is the same as option 1 of the GO MAPPING menu. This menu calls the COGISPLF command.
Keywords used to map input spooled file data automatically
One of the requirements to run the MAPSNDMAIL command is the creation of a Designer template generated in PDF. To extract the content of the spooled file and map it directly onto the body of an e-mail or extract the recipient's and sender's address, there are multiple zones in Designer (zone type METADATA):
Keywords
- mapFrom: Used to retrieve the sender's e-mail address from the spooled file
- mapSend: Used to retrieve the recipient's e-mail address from the spooled file
- mapCopy: Used to retrieve the carbon copy e-mail address from the spooled file
- mapBCopy: Used to retrieve the blind carbon copy e-mail address from the spooled file
- mapNote: Used to retrieve data from the spooled file and map it onto the body of the e-mail sent.
- mapSubject: Used to retrieve data from the spooled file and map it into the subject of the e-mail sent.
Using keywords
To use the keywords configured in the Designer project (listed below), you need to reference them in the MAPSNDMAIL command.
To do so, here are the parameters of the MAPSNDMAIL command listed with their corresponding values:
Name of the parameter of the MAPSNDMAIL command | Value to reference Designer meta data |
---|---|
Send FROM (FROM) | *MAPFROM |
Send TO (TO) | *MAPSEND |
Send CC (CC) | *MACOPY |
Send CCI (CCI) | *MAPBCOPY |
Subject (SUBJECT) | *MAPSUBJCT |
Note (NOTE) | *MAPNOTE |
Configuration
Configuring the environment variable to define the e-mail sender
The sender's e-mail address and its password must be configured in the environment variable of the MAPPING Server. To do so, follow the steps described below:
1) Taper la commande :
WRKENVVAR
2) Créer les variables d'environnement en *SYS pour le fonctionnement avec le sous-système de Mapping contenant l'adresse e-mail et le mot de passe pour l'authentification du serveur SMTP
MAIL_PASSWORD MONMOTDEPASSE MAIL_LOGIN MONADRESSEMAIL
L'adresse e-mail de l'expéditeur stipulée dans la commande MAPSNDMAIL devra être MONADRESSEMAIL.
PS : Dans le cas d'un envoi avec des expéditeurs variables (provenant du spool par exemple), une configuration du serveur SMTP est généralement possible pour autoriser les envois de mail à partir de n'importe quelle adresse mail.
Paramétrage de serveur d'envoi d'emails
Sur l'option 1 du menu GO MAPSND, il faut renseigner les informations du serveur d'envoi d'e-mails :
- Adresse IP du serveur
- Port du serveur
- Domaine du serveur
Attention : Il faut absolument posséder un profil SECOFR pour accéder à ce menu. Si tel n'est pas le cas, l'accès au menu sera impossible et aucun message ne sera affiché.
Exemples
Envoi simple d'un email avec PDF joint
MAPSNDMAIL SPLF(FACTURE) SPLNUM(23) JOB(QPADEV0009) JOBNUM(855068) USER(JDIEU) MAPNAM(MAIL_DOC) MAPSEQ(00010) DELSPL(N) PAGSTR(1) PAGEND(10) STATE(READY)FROM('hotline@mappingsuite.onmicrosoft.com')
TO('jdieu@mappingsuite.onmicrosoft.com') SUBJECT('Mon sujet') NOTE('Ceci est mon corps demail') NAME1('PJ.pdf')
Envoi simple d'un email avec un corps d'email texte dynamique
MAPSNDMAIL SPLF(FACTURE) SPLNUM(23) JOB(QPADEV0009) JOBNUM(855068) USER(JDIEU) MAPNAM(MAIL_DOC) MAPSEQ(00010) DELSPL(N)
PAGSTR(1) PAGEND(10) STATE(READY) FROM('hotline@mappingsuite.onmicrosoft.com')
TO('jdieu@mappingsuite.onmicrosoft.com') SUBJECT('Mon sujet') NOTE('Ceci est mon corps d'email ayant pour donnée dynamique :[[DATE]]') NAME1('PJ.pdf')
Envoi d'un email avec un corps d'email HTML dynamique
Le principe de cette fonctionnalité est d'utiliser un fichier HTML pour le corps de l'email.
Voici un exemple d'un fichier HTML (mail.html) :
<body> <img src="http://www.mappingsuite.com/wp-content/uploads/2018/08/Logo_web1.png"> Cher Monsieur [[NOM]] ayant pour numéro de client [[NUMCLI]], Veuillez trouver ci-joint votre facture nº <font color=red> [[NUMFAC]] en date du [[DATE]] </font>. <b>Cordialement</b> </body>
Attention : Dans le fichier HTML, les caractères spéciaux doivent être écrits avec un codage particulier : https://www.commentcamarche.com/contents/489-caracteres-speciaux-html
Son appel se fait par l'écriture de son chemin et de son nom dans le paramètre NOTE de la commande MAPSNDMAIL :
MAPSNDMAIL SPLF(FACTURE) SPLNUM(23) JOB(QPADEV0009) JOBNUM(855068) USER(JDIEU) MAPNAM(MAIL_DOC) MAPSEQ(00010) DELSPL(N)
PAGSTR(1) PAGEND(10) STATE(READY) FROM('hotline@mappingsuite.onmicrosoft.com')
TO('jdieu@mappingsuite.onmicrosoft.com') SUBJECT('Mon sujet') NOTE('/home/mapsend/mail.html') NAME1('PJ.pdf')
Voici le résultat obtenu :
Cher Monsieur MICALETTI ayant pour numéro de client 9214,
Veuillez trouver ci-joint votre facture nº 1 en date du 23/11/2016 .
Cordialement