05-02-2017 8:05 AM
Hello All,
I create one dynamic internal table and send via email as an attachment to one person using HR_KR_STRING_TO_XSTRING and SCMS_XSTRING_TO_BINARY
DATA : p_email TYPE adr6-smtp_addr VALUE 'abc@gmail.com'.
"Convert Xstring into Binary
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'EXPORTING
buffer = lv_xstringTABLES
binary_tab = lit_binary_content.
CLEAR: l_data.
CONCATENATE 'MG_STOCKSTOTA_' sy-datum INTO l_data.
l_attsubject = l_data.CLEAR l_data.
"Create Attachment
TRY.
lo_document->add_attachment( EXPORTING
i_attachment_type = 'XLS'
i_attachment_subject = l_attsubject
i_att_content_hex = lit_binary_content ).
ENDTRY.
TRY.
lo_sender = cl_sapuser_bcs=>create( sy-uname ). "sender is the logged in user"Set sender to send request
lo_send_request->set_sender(EXPORTING
i_sender = lo_sender ).
ENDTRY.
"Set recipient
lo_recipient = cl_cam_address_bcs=>create_internet_address( p_email ). "Here Recipient is email input p_email
TRY.
lo_send_request->add_recipient(EXPORTING
i_recipient = lo_recipient
i_express = 'X' ).
ENDTRY.
TRY.
CALL METHOD lo_send_request->set_send_immediatelyEXPORTING
i_send_immediately = p_send. "here selection screen input p_send
ENDTRY.
TRY."Send email
lo_send_request->send(EXPORTING
i_with_error_screen = 'X' ).COMMIT WORK.IF sy-subrc = 0. "mail sent successfullyWRITE 😕 'Mail sent successfully'.ENDIF.
ENDTRY.
Now I want to send it to DL(Distribution List) How can I do this.
Please help.
05-02-2017 1:31 PM
In the cl_*_bcs family, try the cl_distributionlist_bcs:
" create recipîent from DLI
lo_recipient = cl_distributionlist_bcs=>getu_persistent( i_dliname = p_dliname i_private = p_private ).
05-02-2017 1:31 PM
In the cl_*_bcs family, try the cl_distributionlist_bcs:
" create recipîent from DLI
lo_recipient = cl_distributionlist_bcs=>getu_persistent( i_dliname = p_dliname i_private = p_private ).