Email APIs - Automatic Creation and Sending of Emails
rContents overview
To enable you to seamlessly integrate directmail into your applications, directmail includes several APIs (program interfaces) and commands that you can use to create and send emails using simple IBM i commands and passed parameters.
The individual steps to create and send e-mails automatically are described in detail here.
OPNEMLAPI - Open E-Mail (menu selection 9)
The first API is used to open an e-mail process. You start the creation of an e-mail with the command OPNEMLAPI.
0251 - Open E-Mail
The names of the parameters are shown below in brackets. E.g. Recipient (RECEIVER).
Mailbox (MAILBOX)
Here you specify in which mailbox the e-mail process is to be opened
Sender (SENDER)
Enter the sender name and e-mail address of the sender of the e-mail.
Under certain circumstances, this information is checked by the SMTP server. The address must then be available on the SMTP server. Otherwise an error message may be displayed: "550-Requested action not taken: mailbox unavailable", or another error message from the SMTP server indicating an error (WRKEML, choice 25 for the unsent e-mail).
The format for the sender is:
SENDER(Max Mouse 'max.maus@acmegmbh.de')
Valid values are:
Sender name and Sender e-mail address
*MAILBOX The information is taken from the mailbox specified in the MAILBOX parameter box defined in the parameter MAILBOX.
Recipient (RECEIVER)
Max. 80 digits
Enter here recipient name and e-mail address of the recipient of the e-mail. The format for the recipient is:
RECEIVER((*TO Gustav Giraffe 'gustav.giraffe@acmegmbh.de') (*CC name 'email...'))
*TO specifies the recipient(s) who should receive the original email,
*CC specifies the recipient(s) who should receive a copy of the email,
*BCC specifies the recipient(s) who should receive the email in "blind copy", i.e. that all other recipients do not know about this copy.
0252 - Open e-mail 2nd page
Subject (SUBJECT)
This is the subject of the e-mail.
Max. Length: 256 characters.
Message body (TEXT) - Content of the body text of the e-mail
List of up to 300 fields of 78 characters each
each field appears in the e-mail on a separate line
however, if a line ends with a plus sign ("+"), then the following line is appended
Examples
TEXT('xxx'' 'yyy+' 'zzz') results in: xxx yyyzzz
Priority (PTY)
Specifies the priority with which the e-mail should be sent
Valid values are:
*HIGH The e-mail will be sent with high priority
*NORMAL The e-mail is sent with normal priority
*LOW The e-mail is sent with low priority
Send priority (SNDPTY)
Specifies the send priority with which the e-mail should be sent. Depending on how the email was created, a send priority is assigned aurtomatically and thus will be sent faster by default..
Valid values are:
1-9 - Allowed send priorities
4 Interactively created e-mails get this priority (default)
5 API e-mails get this priority (default)
7 AutoMail emails get this priority (default)
Read confirmation (CONFIRM)
If the recipient's e-mail program supports this function, you can receive an information when the recipient opens the e-mail.
Valid values are:
*YES The recipient will be asked for a confirmation of receipt
*NO No acknowledgement of receipt is requested
Compress attachments (COMPRESS)
Attachments can be compressed. This is controlled by this parameter.
Valid values for this parameter:
*NO E-mail attachments are not encrypted
*YES E-mail attachments are encrypted
Encrypt e-mail (ENCRYPT)
Use this setting to specify whether the e-mail should be encrypted. Encryption can only be set to *YES if a DM400CRY license is available.
Valid values for this parameter:
*NO E-mails are not encrypted
*YES E-mails will be encrypted
*POSSIBLE Encryption is possible and is set individually for each mail process vidual mail process
*MAILBOX The encryption setting of the mailbox is used
*SYSVAL The encryption setting in the directmail configuration is used
Sign e-mail (SIGN)
directmail also supports the digital signature of e-mails to ensure their authenticity. Signing can only be set to *YES if a DM400CRY license is present.
Valid values for this parameter:
*NO E-mails are not signed
*YES E-mails are digitally signed.
*MAILBOX The signature setting of the mailbox is used
*SYSVAL The signature setting in the directmail configuration is used
IFS Copy Name (IFSBACKUP)
With which name the e-mail should be stored in IFS after sending.
0313 - Open e-mail 3rd page
IFS Copy Path (IFSPATH)
In which directory a copy of the e-mail should be stored in the IFS after sending.
CCSID of the parameter (PARMCCSID)
This value specifies in which CCSID the parameters are passed to the command.
Valid values for this parameter:
Number CCSID table
*CURRENT CCSID of the current job (default value)
*Job CCSID of the current job (default value)
The parameters for email addresses, names, subject and text are then automatically translated into the CCSID of the server jobs.
CCSID of the email (MAILCCSID)
This value specifies the CCSID in which the parameters are passed to the email.
Valid values for this parameter:
Number to use CCSID table
*SERVER Use CCSID of the server
*Job CCSID of the current job (default value)
The parameters for e-mail addresses, names, subject and text are then automatically translated into the CCSID of the server jobs.
WRTEMLAPI - Attach objects to e-mail (menu selection 10)
Any number of attachments can be added to an e-mail once it has been opened using the WRTEMLAPI command. These attachments can be PC documents from the integrated file system of the IBM i, spool files, or IBM i objects such as programs, files and libraries.
Here is a list of all parameters for the WRTEMLAPI command and their possible use depending on the selected object type:
All parameters |
| *SPLF | *SAVF | *IFS | *FILE |
Object type . . . . . . . . . . . | TYPE | X | X | X | X |
Alias filename . . . . . . . . | ALIAS | X | X | X | X |
Compress data . . . . . . . | COMPRESS | X | X | X | X |
Smart Card Signature . | SIGN | X | X | X | X |
Delete object . . . . . . . . . | DLT | X | X | X | X |
Attach text to e-mail . . . . . | ADDTOTXT | X |
| X | X |
Spool file . . . . . . . . . . | FILE | X |
|
|
|
Job name . . . . . . . . . . . . | JOB | X |
|
|
|
User . . . . . . . . . . . |
| X |
|
|
|
Number ... . . . . . . . . . |
| X |
|
|
|
Spool file number . . . . . . . | SPLNBR | X |
|
|
|
Output format . . . . . . . . . | FORMAT | X |
|
|
|
Spool-A-Matic format . . . . . . | GUMBOFMT | X |
|
|
|
Manufacturer, type, model . | MFRTYPMDL | X |
|
|
|
Data station customization object . | WSCST | X |
|
|
|
Library . . . . . . . . . . |
| X |
|
|
|
Page range: | PAGERANGE | X |
|
|
|
Page from . . . . . . . . . . |
| X |
|
|
|
Page up to . . . . . . . . . . |
| X |
|
|
|
Use text only . . . . . . . | TEXTONLY | X |
|
|
|
Green bars . . . . . . . . . . | GREENBAR | X |
|
|
|
Page table . . . . . . . . . | PAGETABLE | X |
|
|
|
Paper size . . . . . . . . . . | PAPERSIZE | X |
|
|
|
Landscape . . . . . . . . . . . | ROTATION | X |
|
|
|
CPI . . . . . . . . . . . . . . | CPI | X |
|
|
|
LPI . . . . . . . . . . . . . . | LPI | X |
|
|
|
PDF Font . . . . . . . . . . . . | FONT | X |
|
|
|
Code page CCSID . . . . . . . . . | CCSID | X |
|
|
|
Create PDF/A . . . . . . . . . . | PDFA | X |
|
|
|
Text origin coordinates: | PDFAREA | X |
|
|
|
X axis mm . . . . . . . . . . |
| X |
|
|
|
X scale . . . . . . . . . |
| X |
|
|
|
Y-axis mm . . . . . . . . . . |
| X |
|
|
|
Scale Y . . . . . . . . . |
| X |
|
|
|
Form first page . . . . . . | OVERLAY | X |
|
|
|
Form Position: | MARGINS | X |
|
|
|
Upper margin mm . . . . . . . . |
| X |
|
|
|
Bottom edge mm . . . . . . . |
| X |
|
|
|
Left margin mm . . . . . . . . |
| X |
|
|
|
Form continuation pages . . . . . . | OVERLAY2 | X |
|
|
|
Form position: | MARGINS2 | X |
|
|
|
Upper margin mm . . . . . . . . |
| X |
|
|
|
Bottom edge mm . . . . . . . |
| X |
|
|
|
Left margin mm . . . . . . . . |
| X |
|
|