OPALE - 10.0 - Utilisation - Envoyer un mail avec un document PDF - MAPSNDMAIL/en

Différence entre versions

De MappingDoc
Ligne 82 : Ligne 82 :
  
 
===4. Displaying e-mail queue===
 
===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.<br />
+
This menu allows you to display previously sent e-mails, which you can filter by user name. This menu calls the MAPDSPMAIL command.<br />
 
'''Caution''': This menu stops you from sending new e-mails so do not leave it open.
 
'''Caution''': This menu stops you from sending new e-mails so do not leave it open.
  

Version du 31 mai 2019 à 09:45

Introduction

With 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 as a parameter ("Mapping format" parameter). The template has to be generated in PDF. It has to include INDEX zones used as dynamic data in the subject, attachment name, or in the e-mail body.

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 Copy
Send CCI . . . . . . . . . . . .    _______________________________________________     Blind Carbon Copy
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 the 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

Managing menus

The menu that allows you to send e-mails is called MAPSND. To access it, run command:

GO MAPSND

MAPSND.jpg

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. Stopping e-mail management

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 previously sent e-mails, which you can filter 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

This 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. Overseeing e-mail operations

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) Run command:

WRKENVVAR

2) Create the environment variables in *SYS so that the Mapping sub-system which contains the e-mail address and the password for the server authentification can work.

MAIL_PASSWORD                MYPASSWORD 
MAIL_LOGIN                   MYEMAILADDRESS 

The sender's e-mail address which is specified in the MAPSNDMAIL command will have to be MYEMAILADRESS.

P.S. If you would like to send an e-mail from different e-mail adresses (coming from the spooled file for instance), you can configure the SMTP server to allow e-mails to be sent from any given e-mail address.

Configuring the server to send e-mails

Select option 1 of the GO MAPSND menu to fill in information about the server:

  • IP address of the server
  • Server port
  • Server domain

Caution: You need to have a SECOFR profile to access this menu.

Examples

Sending an email with a PDF file attached

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('My subject') NOTE('This is the body of this e-mail') NAME1('PJ.pdf')

Sending an email with a dynamic text in the e-mail body

MAPSNDMAIL SPLF(INVOICE) 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('My subject') NOTE('This is the body of my e-mail with dynamic data:[[DATE]]') NAME1('PJ.pdf')

Sending an e-mail with dynamic HTML code in the e-mail body

The aim of this feature is to use an HTML file as the body for the e-mail.

Example of an HTML file (mail.html) :

<body>
<img src="http://www.mappingsuite.com/wp-content/uploads/2018/08/Logo_web1.png">
Dear Sir [[NAME]] client number [[CLINUM]],
Please find attached our invoice nº <font color=red> [[INVNUM]] from the [[DATE]] </font>.
<b>Sincerely</b>
</body>

Caution: Special characters have to be written with appropriate coding in the HTML file: https://www.commentcamarche.com/contents/489-caracteres-speciaux-html


To call this HTML file, you need to specify its path and name in the NOTE parameter of the MAPSNDMAIL command:

MAPSNDMAIL SPLF(INVOICE) 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('My subject') NOTE('/home/mapsend/mail.html') NAME1('PJ.pdf')

Here is the final result:

LOGOMAPPING.jpg
Dear Sir MICALETTI client number 9214,

Please find attached our invoice nº 1 from the 11/23/2016.

Sincerely