ABAP Program to Send External Mail from SAP
Here is a ABAP program which would allow you to send mail to any external system from SAP. Ensure that you have all the required configurations done by the basis team to send the mail out. Well, you need to configure SAP Connect and you can check the status if you the mail was sent out successfully using SCOT. To test if the mail sending is working correctly just send a test mail from SAP Business Workplace (Tcode: SBWP). If you are able to receive the mail from it, then here is the ABAP code, which should work just fine.
* Data Declarations DATA: lt_mailsubject TYPE sodocchgi1. DATA: lt_mailrecipients TYPE STANDARD TABLE OF somlrec90 WITH HEADER LINE. DATA: lt_mailtxt TYPE STANDARD TABLE OF soli WITH HEADER LINE. * Recipients lt_mailrecipients-rec_type = 'U'. lt_mailrecipients-receiver = 'someone@erpdb.info'. APPEND lt_mailrecipients . CLEAR lt_mailrecipients . * Subject. lt_mailsubject-obj_name = 'TEST'. lt_mailsubject-obj_langu = sy-langu. lt_mailsubject-obj_descr = 'Mail Subject'. * Mail Contents lt_mailtxt = 'This is a test mail'. APPEND lt_mailtxt. CLEAR lt_mailtxt. * Send Mail CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1' EXPORTING document_data = lt_mailsubject TABLES object_content = lt_mailtxt receivers = lt_mailrecipients EXCEPTIONS too_many_receivers = 1 document_not_sent = 2 document_type_not_exist = 3 operation_no_authorization = 4 parameter_error = 5 x_error = 6 enqueue_error = 7 OTHERS = 8. IF sy-subrc EQ 0. COMMIT WORK. * Push mail out from SAP outbox SUBMIT rsconn01 WITH mode = 'INT' AND RETURN. ENDIF.
If you like this post, you may as well like these too:
- ABAP Program to Send Mail with Attachment This ABAP program use the function module ‘SO_NEW_DOCUMENT_ATT_SEND_API1′ to send the email with attachment. There are five steps involved in sending the email with attachment. Add Recipients Put in the...
- ABAP Program: Dynamic external perform (call back form) Here the two programs which are calling dynamically. REPORT ZSOURCE2309. PERFORM EXTFORM IN PROGRAM ZSOURCE2310 USING 'CALL_BACK_FORM' SY-CPROG. FORM CALL_BACK_FORM. WRITE / 'I am the call back form in ZSOURCE2309.'....
- ABAP Programs:External perform call This is the simple code which will show you as to how you can call the external routine from the current program. Program 1 REPORT ZSOURCE2307. * List of the...
- ABAP Programs: External flow of control (events) REPORT ZSOURCE0901. * Display a list of customersTABLES CUSTOMERS.SELECT * FROM CUSTOMERS. WRITE / CUSTOMERS-NAME.ENDSELECT. * Event for drill downAT LINE-SELECTION. WRITE: / ‘This line appears after drill-down’. ~~~~~ end...
- ABAP Program: Sample program for OLE Automation REPORT ZSOURCE2801. * Including OLE types INCLUDE OLE2INCL. * Tables and variables for later use TABLES: CUSTOMERS. DATA: APPLICATION TYPE OLE2_OBJECT, WORKBOOK TYPE OLE2_OBJECT, SHEET TYPE OLE2_OBJECT, CELLS TYPE OLE2_OBJECT....
- Create a Program in SAP ABAP You can navigate to the ABAP Editor through the Menu. You can also create favorites for certain transactions and put it into your custom menu. You can type SE38 from...
- SAP ABAP Program Types Each ABAP program has a type, which is defined in the program attributes. What is the purpose of all the different program types? The program type determines which processing blocks...
- Config to Open External URL from IC Webclient Web URL inside CRM IC Web BSP view can be launched using transaction launcher. Follow the steps below: First create URL ID using the path IMG->CRM->IC WebClient->Basic Functions->Transaction Launcher->Define URL’s...
- Generate Temporary ABAP Program Ever had a need to create a temporary program during the run time. Here is a simple program which will allow you to learn that. REPORT ZSOURCE2501. * Internal table...
- Call an ABAP program from a BSP Call an ABAP program from a BSP is somehow impossible due to memory context handling for a web transaction like a BSP. If you try, it would lead to an...
- ABAP Program : Working with Temporary Programs Ever had a need to create a temporary program during the run time. Here is a simple program which will allow you to learn that. REPORT ZSOURCE2501. * Internal table...
- ABAP Program:Reading data from a file REPORT ZSOURCE2602. * Data declarations for later use TABLES CUSTOMERS. PARAMETERS FILENAME(128) DEFAULT '/usr/tmp/testfile.dat' LOWER CASE. DATA: MSG_TEXT(50), ALL_CUSTOMER_NAMES LIKE CUSTOMERS-NAME OCCURS 100 WITH HEADER LINE. * Opening the File...
- ABAP Program:Transferring data to a file (presentation server) REPORT ZSOURCE2603. * Data declarations for later use PARAMETERS FILENAME(128) DEFAULT 'c:usersdefaulttestfile.dat' LOWER CASE. TABLES CUSTOMERS. DATA ALL_CUSTOMERS LIKE CUSTOMERS OCCURS 100 WITH HEADER LINE. * Get data for file...
- ABAP Programs:Sample dialog program (flight reservation) * This program source contains all modules and subroutines of the * flight reservation program, but screen and GUI status definitions * are not included. *&———————————————————————* *&———————————————————————* *& Include MSABBTOP...
- Send email to many users REPORT Z_SEND_EMAIL_to_Users. TABLES: USR02. DATA: C(15). DATA: SENT LIKE SONV-FLAG. DATA: EMAIL_ID LIKE SOFOLENTI1-OBJECT_ID. DATA: BEGIN OF EMAIL_DATA. INCLUDE STRUCTURE SODOCCHGI1. DATA: END OF EMAIL_DATA. DATA: BEGIN OF EMAIL_SEND OCCURS...



















Fantastic,i was searching this since a few day back.thanks