Code: Alles auswählen.
&---------------------------------------------------------------------*
*& Report ZMAIL
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zmail.
PARAMETERS : pa_email TYPE adr6-smtp_addr DEFAULT 'etwas@beispiel.loc'.
DATA: status_mail TYPE bcs_stml.
DATA send_request TYPE REF TO cl_bcs.
DATA requested_status TYPE bcs_rqst VALUE 'E'.
DATA document TYPE REF TO cl_document_bcs.
DATA text TYPE soli_tab.
DATA sender TYPE REF TO cl_sapuser_bcs.
DATA recipient TYPE REF TO if_recipient_bcs.
DATA sent_to_all.
DATA: exception_info TYPE REF TO if_os_exception_info,
bcs_exception TYPE REF TO cx_bcs.
START-OF-SELECTION.
PERFORM send_mail_ohne_att.
END-OF-SELECTION.
*&---------------------------------------------------------------------*
*& Form create_mail
*&---------------------------------------------------------------------*
*----------------------------------------------------------------------*
FORM send_mail_ohne_att.
DATA i_syst TYPE ad_symbdst.
DATA i_client TYPE ad_umand.
DATA i_username TYPE ad_uname.
send_request = cl_bcs=>create_persistent( ).
APPEND 'Hallo zusammen, ' TO text.
APPEND 'das ist eine Testmail' TO text.
APPEND 'vom SAP-Server' TO text.
document = cl_document_bcs=>create_document(
i_type = 'TXT'
i_text = text
* i_length = '4'
i_subject = 'TestMail von SAP' ).
send_request->set_document( document ).
sender = cl_sapuser_bcs=>create( sy-uname ).
send_request->set_sender(
EXPORTING i_sender = sender ).
recipient = cl_cam_address_bcs=>create_internet_address(
pa_email ).
send_request->add_recipient(
EXPORTING
i_recipient = recipient
i_express = 'X' ).
* TRY.
i_syst = sy-sysid.
i_client = sy-mandt.
i_username = sy-uname .
requested_status = 'E'.
status_mail = 'E'.
** Stauts Rückmeldung
send_request->set_status_attributes(
EXPORTING
i_requested_status = requested_status
i_status_mail = status_mail ).
* Sofort Senden nicht warten auf Scot
send_request->set_send_immediately( 'X' ).
* Sende
send_request->send(
EXPORTING
i_with_error_screen = 'X'
RECEIVING
result = sent_to_all ).
IF sent_to_all = 'X'.
WRITE text-003.
ENDIF.
COMMIT WORK.
ENDFORM. " create_mail