on 11-01-2016 12:04 PM
* for the SENDMAIL button<br>
IF gv_user = 'X'.<br>
gv_user = ''.<br>
ELSE.<br>
gv_user = 'X'.<br>
ENDIF.<br>
<br>
FIELD-SYMBOLS: <fs_receiver> TYPE yrecipients.<br>
<br>
TRY.<br>
<br>
lo_send_request = cl_bcs=>create_persistent( ).<br>
<br>
" Write the e-mail text<br>
APPEND 'Dear associate, ...' TO i_text.<br>
APPEND 'Thank you and best regards!' TO i_text.<br>
<br>
" Send in RAW, TXT, HTML etc. format<br>
lo_document = cl_document_bcs=>create_document(<br>
i_type = 'RAW'<br>
i_text = i_text<br>
i_hex = lt_body_hex<br>
i_subject = 'Monthly Billing Error List' ) .<br>
*add the document as an attachment<br>
lo_document->add_attachment(<br>
i_attachment_type = 'xls' " lv_attachment_type<br>
* i_attachment_size = lv_attachment_size<br>
i_attachment_subject = 'attachment' " lv_attachment_subject<br>
i_att_content_hex = lt_att_content_hex ).<br>
* ENDIF.<br>
<br>
" set the e-mail address of the sender:<br>
lo_sender = cl_cam_address_bcs=>create_internet_address( 'do-not-reply@domain.com' ).<br>
<br>
" set the e-mail address of the recipient<br>
SELECT * FROM yrecipients<br>
INTO TABLE gt_recipients<br>
FOR ALL ENTRIES IN gt_recipients<br>
WHERE vkorg = gt_recipients-vkorg.<br>
<br>
LOOP AT gt_recipients ASSIGNING <fs_receiver>.<br>
lo_recipient = cl_sapuser_bcs=>create( sy-uname ).<br>
lo_send_request->add_recipient( lo_recipient ) .<br>
ENDLOOP.<br>
<br>
" assign document to the send request:<br>
lo_send_request->set_document( lo_document ).<br>
<br>
" add the sender:<br>
lo_send_request->set_sender( lo_sender ).<br>
<br>
MOVE space TO lv_with_error_screen.<br>
" SAP Send Email CL_BCS<br>
lv_sent_to_all = lo_send_request->send( lv_with_error_screen ).<br>
<br>
CATCH cx_document_bcs INTO lx_document_bcs.<br>
<br>
CATCH cx_send_req_bcs INTO bcs_error.<br>
bcs_mess = bcs_error->get_text( ).<br>
<br>
ENDTRY.<br>
<br>
ENDFORM.
Have you Seen the Below Standard Example
BCS_EXAMPLE_7
They are fetching the Data from table and concatenate to the long string Lv_string, Then passing it to the class.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
80 | |
9 | |
9 | |
7 | |
7 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.