Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Sending mail using FM SO_OBJECT_SEND

Former Member
0 Likes
5,744

Hi !

I am using FM "SO_OBJECT_SEND" for sending mail to external mail id , like gmail.com,

I have filled in the receivers as follow

l_receivers-RECEXTNAM = '[email protected]'.   " Email Address  "hardcoded for testing

l_receivers-RECESC     = 'U'.       " Receiver type

l_receivers-SNDART     = 'INT'.                            *** let me know whether INT or EMAIL needs to be used.

*WA_RECLIST-SNDPRI     = '1'.

*WA_RECLIST-MAILSTATUS = 'X'.

l_receivers-RCDAT      = SY-DATUM.

l_receivers-RCTIM      = SY-UZEIT.

l_receivers-DELIVER    = 'X'.

l_receivers-NOT_DELI   = 'X'.

l_receivers-SNDEX      = 'X'.       " EXPRESS DOCUMENT

APPEND l_receivers.

My FM call looks like this :

CALL FUNCTION 'SO_OBJECT_SEND'

     EXPORTING

       folder_id                  = l_folder_id

       forwarder                  = c_forwarder

       object_fl_change           = l_object_fl_change

       object_hd_change           = l_object_hd_change

       object_id                  = l_object_id

       object_type                = l_sood-objtp

       outbox_flag                = c_kreuz

       owner                      = l_soud-usrnam

       store_flag                 = l_sonv-flag

     IMPORTING

       object_id_new              = l_object_id

       sent_to_all                = l_sonv-flag

     TABLES

       objcont                    = g_objcont

       objhead                    = l_objhead

       objpara                    = l_objpara

       objparb                    = l_objparb

       receivers                  = l_receivers

Initially when I configured it for SAP ID, I was able to receive mail in my ID. but now this is not happening. Also, I can see  other request in SOST, but mine is not visible.

Please let me know where I am going wrong. Thanks in advance.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,857

Problem is solved, I used FM "SO_NEW_DOCUMENT_ATT_SEND_API1" to solve this with minor modification to my code, and I am able to send mail to my external ID.

Hi !

I am using FM "SO_OBJECT_SEND" for sending mail to external mail id , like gmail.com,

I have filled in the receivers as follow

l_receivers-RECEXTNAM = '[email protected]'.   " Email Address  "hardcoded for testing

l_receivers-RECESC     = 'U'.       " Receiver type

l_receivers-SNDART     = 'INT'.                            *** let me know whether INT or EMAIL needs to be used.

*WA_RECLIST-SNDPRI     = '1'.

*WA_RECLIST-MAILSTATUS = 'X'.

l_receivers-RCDAT      = SY-DATUM.

l_receivers-RCTIM      = SY-UZEIT.

l_receivers-DELIVER    = 'X'.

l_receivers-NOT_DELI   = 'X'.

l_receivers-SNDEX      = 'X'.       " EXPRESS DOCUMENT

APPEND l_receivers.

My FM call looks like this :

CALL FUNCTION 'SO_OBJECT_SEND'

     EXPORTING

       folder_id                  = l_folder_id

       forwarder                  = c_forwarder

       object_fl_change           = l_object_fl_change

       object_hd_change           = l_object_hd_change

       object_id                  = l_object_id

       object_type                = l_sood-objtp

       outbox_flag                = c_kreuz

       owner                      = l_soud-usrnam

       store_flag                 = l_sonv-flag

     IMPORTING

       object_id_new              = l_object_id

       sent_to_all                = l_sonv-flag

     TABLES

       objcont                    = g_objcont

       objhead                    = l_objhead

       objpara                    = l_objpara

       objparb                    = l_objparb

       receivers                  = l_receivers

Initially when I configured it for SAP ID, I was able to receive mail in my ID. but now this is not happening. Also, I can see  other request in SOST, but mine is not visible.

Please let me know where I am going wrong. Thanks in advance.

5 REPLIES 5
Read only

rosenberg_eitan
Active Contributor
0 Likes
2,857

Hi ,

Try this pgm:

REPORT  y_r_eitan_test_31_10 .

TYPE-POOLS: abap .

SELECTION-SCREEN BEGIN OF BLOCK block04 WITH FRAME .

PARAMETERS: p_rcpn_1 TYPE adsmtp-smtp_addr .

PARAMETERS: p_rcpn_2 TYPE adsmtp-smtp_addr .

SELECTION-SCREEN SKIP .

PARAMETERS: p_covt TYPE itcpo-tdtitle .

SELECTION-SCREEN END OF BLOCK block04 .

*----------------------------------------------------------------------*
INITIALIZATION.
   PERFORM at_initialization .

START-OF-SELECTION.
   PERFORM at_start_of_selection .
*----------------------------------------------------------------------*
FORM at_initialization .

   DATA: st_address TYPE bapiaddr3 .

   DATA: it_return TYPE bapirettab .

   CALL FUNCTION 'BAPI_USER_GET_DETAIL'
     EXPORTING
       username = sy-uname
     IMPORTING
       address  = st_address
     TABLES
       return   = it_return.

   p_rcpn_1 = st_address-e_mail .
   p_rcpn_2 = st_address-e_mail .

   CONCATENATE 'Hi there-' sy-datum '-' sy-uzeit '(EX)' INTO p_covt .

ENDFORM .                    "at_initialization
*----------------------------------------------------------------------*
FORM at_start_of_selection .

   DATA: it_soli TYPE soli_tab.

* Using html to make fancy mail....

   APPEND '<U>Hello world!</U>' TO it_soli .
   APPEND '<H3>Hello world!</H3>' TO it_soli .

   DATA: ob_bcs TYPE REF TO cl_bcs.
   DATA: ob_document_bcs  TYPE REF TO cl_document_bcs.
   DATA: ob_sapuser_bcs   TYPE REF TO cl_sapuser_bcs.
   DATA: ob_recipient_bcs TYPE REF TO if_recipient_bcs.

   ob_bcs = cl_bcs=>create_persistent( ).

*  TRY.
   CALL METHOD cl_document_bcs=>create_document
     EXPORTING
       i_type        = 'HTM'
       i_subject     = p_covt
*      i_length      =
*      i_language    = SPACE
        i_importance  = '1'
*      i_sensitivity =
        i_text        = it_soli
*      i_hex         =
*      i_header      =
*      i_sender      =
     RECEIVING
       result        = ob_document_bcs .

   CLEAR it_soli .

   APPEND '<p dir="ltr">' TO it_soli .

   APPEND '<table border="1" cellspacing="0">' TO it_soli .

   APPEND '<tr>' TO it_soli .
   APPEND '<th>h1</th>' TO it_soli .
   APPEND '<th>h2</th>' TO it_soli .
   APPEND '<th>h3</th>' TO it_soli .
   APPEND '<th>h4</th>' TO it_soli .
   APPEND '</tr>' TO it_soli .

   DO 10 TIMES .
     APPEND '<tr>' TO it_soli .
     APPEND '<td>1</td>' TO it_soli .
     APPEND '<td>2</td>' TO it_soli .
     APPEND '<td bgcolor="blue" style="color:yellow">3</td>' TO it_soli .
     APPEND '<td>4</td>' TO it_soli .
     APPEND '</tr>' TO it_soli .
   ENDDO .

   APPEND '</table>' TO it_soli .

   DATA: subject TYPE so_obj_des .

* Create multiple attachments

   DO 3 TIMES .

     MESSAGE s000(oo) WITH 'attachment' sy-index INTO subject .

     TRY.
         CALL METHOD ob_document_bcs->add_attachment
           EXPORTING
             i_attachment_type    = 'htm'
             i_attachment_subject = subject
             i_att_content_text   = it_soli.
       CATCH cx_document_bcs .
     ENDTRY.

   ENDDO .

   CALL METHOD ob_bcs->set_document( ob_document_bcs ).

   ob_sapuser_bcs = cl_sapuser_bcs=>create( sy-uname ).

   CALL METHOD ob_bcs->set_sender
     EXPORTING
       i_sender = ob_sapuser_bcs .

* Create multiple recipients
   ob_recipient_bcs = cl_cam_address_bcs=>create_internet_address( p_rcpn_1 ).

   CALL METHOD ob_bcs->add_recipient
     EXPORTING
       i_recipient = ob_recipient_bcs
       i_express   = abap_true.

   ob_recipient_bcs = cl_cam_address_bcs=>create_internet_address( p_rcpn_2 ).

   CALL METHOD ob_bcs->add_recipient
     EXPORTING
       i_recipient = ob_recipient_bcs
       i_express   = abap_true.

   DATA: result TYPE abap_bool .

   CALL METHOD ob_bcs->send
     EXPORTING
       i_with_error_screen = abap_true
     RECEIVING
       result              = result.

   COMMIT WORK .

ENDFORM.                    "at_start_of_selection

Read only

0 Likes
2,857

Hi Eitan,

Thanks for reply, but could you help me with the FM "SO_OBJECT_SEND". As, I want to correct the error, and not on changing the whole logic.

Regards,

Madhwendra

Read only

0 Likes
2,857
Read only

Former Member
0 Likes
2,857

Hi ,

            Please check dis link "http://wiki.sdn.sap.com/wiki/display/Snippets/Abap+EMAIL+Program"

FORM init_rec TABLES receivers STRUCTURE soos1.

  CLEAR receivers.

  REFRESH receivers.

  MOVE sy-datum  TO receivers-rcdat .

  MOVE sy-uzeit  TO receivers-rctim.

MOVE '1'       TO receivers-sndpri.

  MOVE 'X'       TO receivers-sndex.

  MOVE 'U-'      TO receivers-recnam.

  MOVE 'U'       TO receivers-recesc.

  MOVE 'INT'     TO receivers-sndart.

  MOVE '5'       TO receivers-sortclass.

  APPEND receivers.

ENDFORM.

Regard's

Smruti

Read only

Former Member
0 Likes
2,858

Problem is solved, I used FM "SO_NEW_DOCUMENT_ATT_SEND_API1" to solve this with minor modification to my code, and I am able to send mail to my external ID.