ABAP Program to Send External Mail from SAP

Here is a ABAP tutorial 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. Check the post of sending email with attachment if that is your requirement.

* 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
    document_data              = lt_mailsubject
    object_content             = lt_mailtxt
    receivers                  = lt_mailrecipients
    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.
*   Push mail out from SAP outbox
  SUBMIT rsconn01 WITH mode = 'INT' AND RETURN.