on 07-28-2011 11:43 AM
Hello ALL,
I have a requirement of sending an email on click of a button. I have navigated through the class CL_BCS,
but I am anable to understand certain things. First is : WHAT IS THE USE OF CREATE_PERSISTENT ???
Second: which method would send an email?
How do I add the sender's email id and receipent's email id?
I believe create persistent method will create instance of CL_BCS and provide the instance of send request
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
you can ignore the add attachment method in the code
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
TRY.
create persistent send request
lp_send_request = cl_bcs=>create_persistent( ).
Get the text
IF iv_stxt IS NOT INITIAL.
CALL METHOD zfi_flexgl_common=>read_text
EXPORTING
iv_stxt = iv_stxt
IMPORTING
et_tline = lt_tline
ev_failed = ev_failed.
LOOP AT lt_tline INTO ls_tline.
APPEND ls_tline-tdline TO lt_text.
ENDLOOP.
ENDIF.
create and set document
create document from internal table with text
lp_document = cl_document_bcs=>create_document(
i_type = iv_format_type "'XLS' "HTM'
i_text = lt_text
i_subject = iv_msg_subj ).
IF it_attach IS NOT INITIAL.
Add attachment
DATA: l_size TYPE sood-objlen, " Size of Attachment
l_lines TYPE i. " Lines count
*
l_lines = LINES( it_attach ).
l_size = l_lines * 255.
CALL METHOD lp_document->add_attachment
EXPORTING
i_attachment_type = 'RAW'
i_attachment_subject = 'My attachment'
i_attachment_size = l_size
i_att_content_text = it_attach.
ENDIF.
add document to send request
CALL METHOD lp_send_request->set_document( lp_document ).
Sender addess
*l_sender = cl_sapuser_bcs=>create( sy-uname ).
*call method l_send_request->set_sender
exporting
i_sender = l_sender.
LOOP AT it_rec INTO ls_rec.
lv_receiver = iv_rec.
TRY.
CALL METHOD cl_cam_address_bcs=>create_internet_address
EXPORTING
i_address_string = lv_receiver
RECEIVING
result = lp_recipient.
CATCH cx_address_bcs .
ENDTRY.
CALL METHOD lp_send_request->add_recipient
EXPORTING
i_recipient = lp_recipient
i_blind_copy = abap_true
i_express = abap_true.
ENDLOOP.
IF sy-subrc <> 0.
ev_failed = abap_true.
EXIT.
ENDIF.
---------- send document ---------------------------------------
CALL METHOD lp_send_request->send(
RECEIVING
result = lv_flag ).
CATCH cx_send_req_bcs.
ev_failed = abap_true.
CATCH cx_document_bcs.
ev_failed = abap_true.
ENDTRY.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.