Hi,
Searching for other posts suggested the use of cl_bcs class set_message_subject method to insert a title email with more than 50 characters. I used the code below, but the title of the email is empity in SOST transaction. can help me?
*&---------------------------------------------------------------------*
*& Report ZSAPN_SEND_EMAIL
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zsapn_send_email.
DATA: lo_send_request TYPE REF TO cl_bcs VALUE IS INITIAL.
CLASS cl_bcs DEFINITION LOAD.
DATA: lo_document TYPE REF TO cl_document_bcs VALUE IS INITIAL. "document object
DATA : i_text TYPE bcsy_text. "Table for body
DATA : w_text LIKE LINE OF i_text. "work area for message body
DATA: lo_sender TYPE REF TO if_sender_bcs VALUE IS INITIAL. "sender
DATA: lo_recipient TYPE REF TO if_recipient_bcs VALUE IS INITIAL. "recipient
* data: send_request type ref to cl_bcs.
**Selection screen
PARAMETERS : p_email TYPE adr6-smtp_addr. "Emai input
PARAMETERS: p_sub TYPE string." "email subject
PARAMETERS : p_send AS CHECKBOX. "send immediatly flag
START-OF-SELECTION.
lo_send_request = cl_bcs=>create_persistent( ).
* Message body and subject
*Set body
w_text-line = 'This is the first tutorial of sending email using SAP ABAP programming by SAPNuts.com'.
APPEND w_text TO i_text.
CLEAR w_text.
w_text-line = 'SAPNuts.com is the best SAP ABAP learning portal'.
APPEND w_text TO i_text.
CLEAR w_text.
lo_document = cl_document_bcs=>create_document( "create document
i_type = 'TXT' "Type of document HTM, TXT etc TXT
i_text = i_text "email body internal table
* i_length = '12'
i_subject = ' ' ). "email subject here p_sub input parameter p_sub
* Pass the document to send request
lo_send_request->set_document( lo_document ).
data t_sub TYPE string.
t_sub = p_sub.
CALL METHOD lo_send_request->set_message_subject
EXPORTING
ip_subject = t_sub.
TRY.
lo_sender = cl_sapuser_bcs=>create( sy-uname ). "sender is the logged in user
* Set sender to send request
lo_send_request->set_sender(
EXPORTING
i_sender = lo_sender ).
* CATCH CX_ADDRESS_BCS.
****Catch exception here
ENDTRY.
**Set recipient
lo_recipient = cl_cam_address_bcs=>create_internet_address( p_email ). "Here Recipient is email input p_email
TRY.
lo_send_request->add_recipient(
EXPORTING
i_recipient = lo_recipient
i_express = 'X' ).
* CATCH CX_SEND_REQ_BCS INTO BCS_EXCEPTION .
**Catch exception here
ENDTRY.
TRY.
CALL METHOD lo_send_request->set_send_immediately
EXPORTING
i_send_immediately = p_send. "here selection screen input p_send
* CATCH CX_SEND_REQ_BCS INTO BCS_EXCEPTION .
**Catch exception here
ENDTRY.
TRY.
** Send email
lo_send_request->send(
EXPORTING
i_with_error_screen = 'X' ).
COMMIT WORK.
IF sy-subrc = 0. "mail sent successfully
WRITE :/ 'Mail sent successfully'.
ENDIF.
* CATCH CX_SEND_REQ_BCS INTO BCS_EXCEPTION .
*catch exception here
ENDTRY.