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 storedValue Char ISSUERMAIL : # the issuer of this emailValue Char A_USER()(1..) : # tab of principal recipientValue Char CC_USER()(1..): # tab of carbon copy recipientValue Char HEADER : # subjectValue Clbfile BODY : # text of the mailValue Char ATTACHMENTS()(1..) : # tab of path of attachmentsValue 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 :

ValueMeaning
[V]CST_AOKeverything is OK.
[V]CST_AINFOAt least an attachment isn’t available.
[V]CST_AERRORAn 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 STALocal Integer TRACELocal 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)="john@dummy.com"A_USER(2)="martin@dummy.com"CC_USER(1)="christophe@dummy.com"CC_USER(2)="henry@somewhere.com"HEADER="The record was read"ISSUERMAIL="myself@dummy.com"TRACE = 2ATTACHMENTS(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)