SAP Email Send using ABAP efg_gen_send_email Function Call
Sending email from an ABAP report using efg_gen_send_email function call can be easily managed.
If your business requirement does not require to send attachment with email, ABAP developers can use efg_gen_send_email to send SAP email.
Here is the part of the email send by SAP system used by efg_gen_send_email function call.
You can find the ABAP source codes of the sample ABAP report zemailexample below.
Here is the ABAP code of example SAP email send report.
REPORT zemailexample .
DATA :
gs_t005t TYPE t005t,
gt_t005t TYPE TABLE OF t005t.
SELECT * FROM t005t INTO TABLE gt_t005t WHERE spras = 'E'.
DATA :
gv_sender TYPE string, " Sender Email Address
gv_recipient TYPE string, " Recipients Email Address
gv_title TYPE string, " Email Subject
gv_soli_tab TYPE soli_tab, " Email Body
gv_soli_tab_line TYPE LINE OF soli_tab.
gv_title = 'T005 SAP Country Table'.
gv_sender = 'sender@email.com'.
gv_recipient = 'recipient@email.com'.
LOOP AT gt_t005t INTO gs_t005t.
CONCATENATE gs_t005t-land1 ' - ' gs_t005t-landx INTO gv_soli_tab_line.
APPEND gv_soli_tab_line TO gv_soli_tab.
ENDLOOP.
CALL FUNCTION 'EFG_GEN_SEND_EMAIL'
EXPORTING
i_title = gv_title
i_sender = gv_sender
i_recipient = gv_recipient
i_flg_send_immediately = 'X'
TABLES
i_tab_lines = gv_soli_tab
"i_flg_commit = 'X'
EXCEPTIONS
not_qualified = 1
failed = 2
OTHERS = 3.