You may have had a need to send mail through code, and you may have seen other blog posts on usage of GSERMES. But starting with v7 and higher because there is no desktop client that code may not work instead you can use ASYRMAIL.ASEND_MAIL API
Before we get to the example, review online help and search for ASYRMAIL.ASEND_MAIL API.
In below example I am adding a button to classic function Sales order, to send an email.
$ACTIONCase ACTION When "EXEBOUT" : Gosub BOUTONEndcaseReturn
If BOUT="7" ###### this is the code of our button in Window dictionary 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..)
HEADER="The record was read" ISSUERMAIL="email@example.com" TRACE = 2
Append BODY , 'This is an email from SOH window button '+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) If STA <> [V]CST_AOK Then infbox( mess(1163,196,1)) else infbox( "Ëmail was sent nice!") Endif EndifReturn
Conclusion: You can use ASYRMAIL.ASEND_MAIL API to send email programmatically.
I need help to send a mail in html format.
Has anyone got it yet?
In this example yes it's hard coded.But depends on the context it could come from screen field on the classic side and so on.
Is the e-mail recipient just hard coded in this example? Could you define it dynamically?