DATA(lo_document_ref) = cl_document_bcs=>create_document(
i_type = lc_doc_type
i_text = lt_content_txt
i_subject = lv_subject ).
DATA(lo_send_request_ref) = cl_bcs=>create_persistent( ).
lo_send_request_ref->set_message_subject(
EXPORTING
ip_subject = CONV string( lv_subject ) ).
PARAMETERS : p_email TYPE ad_smtpadr. "abc@gmail.com
DATA: lv_subject TYPE char100 VALUE
'Action Required: Check if you can put more than 50 characters'.
DATA(lo_send_request_ref) = cl_bcs=>create_persistent( ).
*Populate sender name
DATA(lo_sender_ref) = cl_sapuser_bcs=>create( sy-uname ).
IF lo_send_request_ref IS BOUND.
IF lo_sender_ref IS BOUND.
*Add sender to send request
lo_send_request_ref->set_sender(
EXPORTING
i_sender = lo_sender_ref ).
* If need to send more than 50 characters in length as a subject line
* Then set message in cl_bcs->set_message_subject
* else populate it in method cl_document_bcs=>create_document
lo_send_request_ref->set_message_subject(
EXPORTING
ip_subject = CONV string( lv_subject ) ).
ENDIF.
ENDIF.
DATA(lo_recipient_ref) = cl_cam_address_bcs=>create_internet_address( p_email ).
IF lo_recipient_ref IS BOUND.
*Add recipient to send request
lo_send_request_ref->add_recipient(
EXPORTING
i_recipient = lo_recipient_ref
i_express = abap_true ).
ENDIF.
DATA(lt_content_txt) = VALUE soli_tab( ( line = 'Hello Team,' )
( line = 'This e-mail has been automatically generated. Please do not reply to this e-mail.' )
( line = 'Thank You!' ) ).
* Create document for e-mail content
DATA(lo_document_ref) = cl_document_bcs=>create_document(
i_type = 'TXT'
i_text = lt_content_txt
* i_subject = CONV so_obj_des( lv_subject ) ).
i_subject = space ).
IF lo_document_ref IS BOUND.
* Add document to send request
lo_send_request_ref->set_document( lo_document_ref ).
ENDIF.
* Set parameter to send e-mail immediately
lo_send_request_ref->set_send_immediately(
EXPORTING
i_send_immediately = abap_true ).
* Send email
DATA(lv_sent_to_all) = lo_send_request_ref->send( ).
* If e-mail is successful then do commit work
IF lv_sent_to_all = abap_true.
COMMIT WORK AND WAIT.
ENDIF.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.