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

Send email to distribution list using cl_bcs

Former Member
0 Likes
4,500

Does anyone know how to send email to a distribution list using class ?

Below is code to send email to internet address recipient, but I want to send to a distribution list instead.

DATA: recipient TYPE REF TO if_recipient_bcs,

send_request TYPE REF TO cl_bcs.

recipient = cl_cam_address_bcs=>create_internet_address(

'xmy@zzz.com' ).

  • add recipient with its respective attributes to send request

CALL METHOD send_request->add_recipient

EXPORTING

i_recipient = recipient

i_express = 'X'.

CALL METHOD send_request->send(

EXPORTING

i_with_error_screen = 'X'

RECEIVING

result = sent_to_all ).

IF sent_to_all = 'X'.

WRITE 'Email successfully created and sent'.

ENDIF.

COMMIT WORK.

2 REPLIES 2
Read only

former_member194669
Active Contributor
0 Likes
1,747

Hi,

Check this


*&---------------------------------------------------------------------*
* Form f_get_distributionList                                          *
*&---------------------------------------------------------------------*
* For get users from  distribution list                               *
*&---------------------------------------------------------------------*
form f_get_distribution_list.
  data : v_flg1 type c.
  refresh : i_selection_tab, i_return.
  clear : i_selection_tab, i_return, wa_address, i_user.

  if vshared eq 'X'.
    v_flg1 = 'X'.
  endif.
  if not soid-objnam is initial.
    call function 'SO_DLI_READ_API1'
      exporting
        dli_name                   = soid-objnam
        shared_dli                 = 'X'
      tables
        dli_entries                = i_distlist
      exceptions
        dli_not_exist              = 1
        operation_no_authorization = 2
        parameter_error            = 3
        x_error                    = 4
        others                     = 5.
    if sy-subrc <> 0.
    else.
      loop at i_distlist.
        if i_distlist-member_adr is initial.
          move i_distlist-member_nam to i_user-bapibname.
          call function 'BAPI_USER_GET_DETAIL'
            exporting
              username = i_user-bapibname
            importing
              address  = wa_address
            tables
              return   = i_return.
          move wa_address-e_mail to wa_receiver-receiver.
          append wa_receiver to i_receiver.
        else.
          move i_distlist-member_adr to wa_receiver-receiver.
          append wa_receiver to i_receiver.
        endif.
      endloop.
    endif.
  endif.

endform.                                 " F_get_distribution_list

a®

Read only

Former Member
0 Likes
1,747

Thanks. It works. I can also use differenct class cl_distributionlist_bcs

recipient =

cl_distributionlist_bcs=>getu_persistent( i_dliname = dist_list

i_private = ' ').

CALL METHOD send_request->add_recipient

EXPORTING

i_recipient = recipient

i_express = 'X'

Now I have problem that how do I set the send date and time as a future date and time.

Thanks