In ax, users sometimes need to send fixed-format emails. In ax, the mail template function is provided. The mail template uses two tables.
- Sysemailtable
- Sysemailmessagetable
Sysemailtable stores the header, and sysemialmessagetable stores the content of the mail template.
Now we call the system sysemailtable: Sendmail () to send Emails: (set the parameters of the email server in system settings first)
Static void sendemail (ARGs _ ARGs)
{
Map map = new map (types: String, types: string );
Sysemailtable = sysemailtable: Find ("alerts ");
Session session = new session ();
Languageid;
;
Languageid = session. interfacelanguage (); // obtain the current languageid
Map. insert ("message", "helloworld ");
Map. insert ("for", "macro. Feng ");
Map. insert ("occurred", "AAA ");
Map. insert ("company", "NJ ");
Map. insert ("Event", "nj_event ");
Map. insert ("data", "No data !!! ");
Map. insert ("subject", "no subject ");
If (! Sysemailtable)
Return;
Sysemailtable: Sendmail (sysemailtable. emailid,
Languageid,
"Macro.feng@py.nelson-jewellery.com ",
Map );
Return;
}
AboveCodeThe map in is used to specify the parameters in the mail template. the Sendmail method calls the sysemailmessage: stringexpand () method to replace the parameters in the template with the map key value.