Api ASYRMAIL.ASEND_MAIL
The following subprogram (called by func
) sends a mail from V7 native code.
Main principles of sending mail in V7
Sending mail with V6 uses an executable called meladx
located on the server. This new library calls "meladx" in the V7 context.
The library "ASYRMAIL" contains a routine called ASEND_MAIL
.
Parameters of the function
The parameters of the funprog are the following:
#
# ASEND_MAIL : Sends an email
#
Funprog ASEND_MAIL(ACTX,ISSUERMAIL,A_USER,CC_USER,HEADER,BODY,ATTACHMENTS,MOD_TRACE)
Variable Instance ACTX Using =[V]CST_C_NAME_CLASS_CONTEXT : # Context where the errors messages are stored
Value Char ISSUERMAIL : # the issuer of this email
Value Char A_USER()(1..) : # tab of principal recipient
Value Char CC_USER()(1..) : # tab of carbon copy recipient
Value Char HEADER : # subject
Value Clbfile BODY : # text of the mail
Value Char ATTACHMENTS()(1..) : # tab of path of attachments
Value Integer MOD_TRACE : # mode trace CST_AYES or CST_ANO
When the log mode is enabled by setting MOD_TRACE to CST_AYES, a log file is created in [TMP] volume.
Return values
The return status is based on "ASTATUS" and the possible value are :
Value | Meaning |
---|---|
[V]CST_AOK | everything is OK. |
[V]CST_AINFO | At least an attachment isn’t available. |
[V]CST_AERROR | An error occured during the sending process. |
Example
If you want to send an email in the "AREAD_AFTER" event, the code would look like this:
Local Integer STA
Local Integer TRACE
Local Char FIC_TRACE(250)
Local Char ISSUERMAIL(250)
Local Char A_USER(250)(1..)
Local Char CC_USER(250)(1..)
Local Char HEADER(250)
Local Clbfile BODY(0)
Local Char ATTACHMENTS(250)(1..)
A_USER(1)="[email protected]"
A_USER(2)="[email protected]"
CC_USER(1)="[email protected]"
CC_USER(2)="[email protected]"
HEADER="The record was read"
ISSUERMAIL="[email protected]"
TRACE = 2
ATTACHMENTS(1) = "[ATT]/test.jpeg"
ATTACHMENTS(3) = "[ATT]/a_cancel.jpg"
ATTACHMENTS(2) = "[ATT]/attachement.doc"
Append BODY , 'This is an example of an email sent from Sage X3 '+chr$(10)
Append BODY , 'I hope you will enjoy it'+chr$(10)
STA =func ASYRMAIL.ASEND_MAIL(GACTX,ISSUERMAIL,A_USER,CC_USER,HEADER,BODY,ATTACHMENTS,TRACE)