12-18-2008 2:06 AM
Email (with attachment) using cl_bcs class. How to:
1. I can only change the email subject name. How to change name of the attachment?
2. There is no email content below. How to add some message to email content?
Here my code:
TRY.
---------- create persistent send request ----------------------
send_request = cl_bcs=>create_persistent( ).
---------- add document ----------------------------------------
get PDF xstring and convert it to BCS format
lp_pdf_size = XSTRLEN( ls_formoutput-pdf ).
pdf_content = cl_document_bcs=>xstring_to_solix(
ip_xstring = ls_formoutput-pdf ).
document = cl_document_bcs=>create_document(
i_type = 'PDF'
i_hex = pdf_content
i_length = lp_pdf_size
i_subject = v_email_subject ). "#EC NOTEXT
add document to send request
send_request->set_document( document ).
---------- add recipient (e-mail address) ----------------------
recipient = cl_cam_address_bcs=>create_internet_address(
i_address_string = v_email_addr ).
add recipient to send request
send_request->add_recipient( i_recipient = recipient ).
---------- send document ---------------------------------------
sent_to_all = send_request->send(
i_with_error_screen = 'X' ).
IF sent_to_all = 'X'.
" MESSAGE i022(so).
MESSAGE i703(zsd) WITH gv_shipto_party v_email_addr.
ENDIF.
---------- explicit 'commit work' is mandatory! ----------------
COMMIT WORK.
------------------------------------------------------------------
* exception handling
------------------------------------------------------------------
* replace this very rudimentary exception handling
* with your own one !!!
------------------------------------------------------------------
CATCH cx_bcs INTO bcs_exception.
WRITE: text-001.
WRITE: text-002, bcs_exception->error_type.
EXIT.
ENDTRY.
12-18-2008 2:54 AM
12-18-2008 2:54 AM