Hi
Still no luck.
---------------
Full Code:
---------------
REPORT ysend_email.
* This example shows how to send
* - a simple text provided in an internal table of text lines
* - and an attached MS word document provided in internal table
* - to some internet email address.
*
* All activities done via facade CL_BCS!
DATA: send_request TYPEREFTO cl_bcs.
DATA: text TYPE bcsy_text.
DATA: binary_content TYPE solix_tab.
DATA: binary_content2 TYPE solix_tab.
DATA: document TYPEREFTO cl_document_bcs.
DATA: sender TYPEREFTO cl_sapuser_bcs.
DATA: custom_sender TYPEREFTO cl_cam_address_bcs.
DATA: lo_sender TYPEREFTO if_sender_bcs.
DATA: convert TYPEREFTO cl_bcs_convert.
DATA: recipient TYPEREFTO if_recipient_bcs.
DATA: bcs_exception TYPEREFTO cx_bcs.
DATA: sent_to_all TYPE os_boolean.
TYPES: BEGINOF gty_data,
col1 TYPEc LENGTH 10,
col2 TYPEc LENGTH 10,
col3 TYPEc LENGTH 10,
END OF gty_data.
DATA: gwa_data TYPE gty_data.
DATA: gt_data TYPESTANDARDTABLEOF gty_data.
START-OF-SELECTION.
PERFORM main.
*---------------------------------------------------------------------*
* FORM main *
*---------------------------------------------------------------------*
FORM main.
TRY.
* -------- create persistent send request ------------------------
send_request = cl_bcs=>create_persistent( ).
* -------- create and set document with attachment ---------------
* create document from internal table with text
APPEND'Hello world!'TOtext.
document = cl_document_bcs=>create_document(
i_type = 'RAW'
i_text = text
i_length = '12'
i_subject = 'Test Immediate' ).
* add attachment to document
* BCS expects document content here e.g. from document upload
* binary_content = ...
gwa_data-col1 = 'FirstName'.
gwa_data-col2 = 'MName'.
gwa_data-col3 = 'LastName'.
APPEND gwa_data TO gt_data.
CLEAR: gwa_data.
gwa_data-col1 = 'First'.
gwa_data-col2 = 'Middle'.
gwa_data-col3 = 'Last'.
APPEND gwa_data TO gt_data.
CONSTANTS: con_cret TYPExVALUE'0D', "OK for non Unicode
con_tab TYPExVALUE'09'. "OK for non Unicode
DATA: lv_string TYPE string.
DATA: lv_string2 TYPE string.
DATA: sizeTYPE so_obj_len,
lv_message TYPE string.
CONSTANTS: lc_tabdel TYPEcVALUE cl_abap_char_utilities=>horizontal_tab,
lc_newline TYPEcVALUE cl_abap_char_utilities=>newline.
DATA: lv_str_line LIKE solix-line.
LOOPAT gt_data INTO gwa_data.
CONCATENATE gwa_data-col1 gwa_data-col2 gwa_data-col3 INTO lv_string SEPARATEDBY lc_tabdel.
CONCATENATE lv_string2 lv_string INTO lv_string2.
CLEAR: gwa_data.
ENDLOOP.
TRY.
cl_bcs_convert=>string_to_solix(
EXPORTING
iv_string = lv_string2
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) INTO lv_message .
ENDTRY.
CALLMETHOD document->add_attachment
EXPORTING
i_attachment_type = 'XLS'
i_attachment_subject = 'My attachment2'
i_att_content_hex = binary_content.
* add document to send request
CALLMETHOD send_request->set_document( document ).
* --------- set sender -------------------------------------------
* note: this is necessary only if you want to set the sender
* different from actual user (SY-UNAME). Otherwise sender is
* set automatically with actual user.
sender = cl_sapuser_bcs=>create( sy-uname ).
CALLMETHOD send_request->set_sender
EXPORTING
i_sender = sender.
* --------- add recipient (e-mail address) -----------------------
* create recipient - please replace e-mail address !!!
recipient = cl_cam_address_bcs=>create_internet_address(
'name@domain.com' ).
* add recipient with its respective attributes to send request
CALLMETHOD send_request->add_recipient
EXPORTING
i_recipient = recipient
i_express = 'X'.
send_request->set_send_immediately( 'X' ).
* ---------- send document ---------------------------------------
CALLMETHOD send_request->send(
EXPORTING
i_with_error_screen = 'X'
RECEIVING
result = sent_to_all ).
IF sent_to_all = 'X'.
WRITEtext-003.
ENDIF.
COMMITWORK.
* -----------------------------------------------------------
* * exception handling
* -----------------------------------------------------------
* * replace this very rudimentary exception handling
* * with your own one !!!
* -----------------------------------------------------------
CATCH cx_bcs INTO bcs_exception.
WRITE: 'Fehler aufgetreten.'(001).
WRITE: 'Fehlertyp:'(002), bcs_exception->error_type.
EXIT.
ENDTRY.
ENDFORM. "main