Hi,
I am able to send the excel file as an attachment to the email address but I have a problem of have a problem of how to password protect the file and then send it. I have the code to send an excel as an attachment as below:
TRY.
cl_bcs_convert=>string_to_solix(
EXPORTING
iv_string = iv_str
iv_codepage = '4103' "suitable for MS Excel, leave empty
iv_add_bom = 'X' "for other doc types
IMPORTING
et_solix = binary_content
ev_size = size ).
CATCH cx_bcs.
MESSAGE e445(so).
ENDTRY.
* send email
TRY.
* -------- create persistent send request ------------------------
send_request = cl_bcs=>create_persistent( ).
* -------- create and set document with attachment ---------------
* create document object from internal table with text
APPEND text-001 TO main_text.
document = cl_document_bcs=>create_document(
i_type = 'RAW'
i_text = main_text
i_subject = 'Employee Data' ).
* add the spread sheet as attachment to document object
document->add_attachment(
i_attachment_type = 'xls'
i_attachment_subject = 'Employee Data'
i_attachment_size = size
i_att_content_hex = binary_content ).
* add document object to send request
send_request->set_document( document ).
* --------- add recipient (e-mail address) -----------------------
* create recipient object
recipient = cl_cam_address_bcs=>create_internet_address( p_em_to ).
* add recipient object to send request
send_request->add_recipient( recipient ).
* ---------- send document ---------------------------------------
sent_to_all = send_request->send( i_with_error_screen = 'X' ).
COMMIT WORK.
But the problem is how to password protect the file before attaching it to the mail. I have never done that before so dont know how to do that in SAP ABAP. Please assist.
Thanks,
Ashok