Skip to Content
0
Jun 03, 2009 at 06:38 PM

Email to external address

41 Views

I am using the below code to send emails to external address and getting error... let me if there's something wrong in the code..........

DATA: gs_obj_hd_change TYPE sood1.
DATA: gt_rec_tab TYPE STANDARD TABLE OF soos1.
DATA: gt_objcont TYPE STANDARD TABLE OF soli.

DATA: WA_REC_TAB TYPE SOOS1,
      WA_OBJCONT TYPE SOLI.

*   Subject
gs_obj_hd_change-objdes = 'Test Email from SAP'.

*   Recipient
WA_rec_tab-recextnam = 'Text-001'. " contains email.
WA_rec_tab-recesc    = 'U'.
APPEND WA_rec_tab TO gt_rec_tab.

* content.

wa_objcont-LINE = 'line1'.
append wa_objcont to gt_objcont.

CALL FUNCTION 'SO_OBJECT_SEND'
  EXPORTING
    object_hd_change           = gs_obj_hd_change " Subject
    object_type                = 'RAW'
    owner                      = sy-uname
  TABLES
    objcont                    = gt_objcont " Content
    receivers                  = gt_rec_tab " Recipient
  EXCEPTIONS
    active_user_not_exist      = 1
    communication_failure      = 2
    component_not_available    = 3
    folder_not_exist           = 4
    folder_no_authorization    = 5
    forwarder_not_exist        = 6
    note_not_exist             = 7
    object_not_exist           = 8
    object_not_sent            = 9
    object_no_authorization    = 10
    object_type_not_exist      = 11
    operation_no_authorization = 12
    owner_not_exist            = 13
    parameter_error            = 14
    substitute_not_active      = 15
    substitute_not_defined     = 16
    system_failure             = 17
    too_much_receivers         = 18
    user_not_exist             = 19
    originator_not_exist       = 20
    x_error                    = 21
    OTHERS                     = 22.
IF sy-subrc EQ  0.
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
          WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.