This document contains code to send an email programmatically using SAP functions. It defines variables to store the email subject, body, and receiver. The body and receiver are appended to internal tables. The SO_NEW_DOCUMENT_SEND_API1 function is called to send the email, passing the document header, body table, and receiver table. It checks the return code and displays a message indicating if the email was sent successfully or not.
This document contains code to send an email programmatically using SAP functions. It defines variables to store the email subject, body, and receiver. The body and receiver are appended to internal tables. The SO_NEW_DOCUMENT_SEND_API1 function is called to send the email, passing the document header, body table, and receiver table. It checks the return code and displays a message indicating if the email was sent successfully or not.
This document contains code to send an email programmatically using SAP functions. It defines variables to store the email subject, body, and receiver. The body and receiver are appended to internal tables. The SO_NEW_DOCUMENT_SEND_API1 function is called to send the email, passing the document header, body table, and receiver table. It checks the return code and displays a message indicating if the email was sent successfully or not.
DATA: objcont LIKE solisti1 OCCURS 0 WITH HEADER LINE.
DATA: reclist LIKE somlreci1 OCCURS 0 WITH HEADER LINE.
DATA: doc_chng LIKE sodocchgi1. * Email subject line doc_chng-obj_descr = 'Email subject'. * Email body objcont = 'This is a line to be sent in the email body'. APPEND objcont. * Receiver list reclist-receiver = 'your email address here'. reclist-rec_type = 'U'. APPEND reclist. * Send the document CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1' EXPORTING document_data = doc_chng commit_work = 'X' TABLES object_content = objcont receivers = reclist EXCEPTIONS too_many_receivers = 1 document_not_sent = 2 operation_no_authorization = 4 OTHERS = 99. IF sy-subrc <> 0. MESSAGE 'Email could not be sent' TYPE 'I'. ELSE. MESSAGE 'Email was sent successfully' TYPE 'I'. ENDIF.