REPORT zemail.
DATA: send_request TYPE REF TO cl_bcs,
text TYPE bcsy_text,
document TYPE REF TO cl_document_bcs,
sender TYPE REF TO cl_cam_address_bcs,
recipient TYPE REF TO cl_cam_address_bcs,
bcs_exception TYPE REF TO cx_bcs,
sent_to_all TYPE os_boolean.
BREAK-POINT.
TRY.
send_request = cl_bcs=>create_persistent( ).
APPEND '<!doctype html public "-//w3c//dtd html 3.2 final//en">' TO text.
APPEND '<html>' TO text.
APPEND ' <head>' TO text.
APPEND ' <title>Título</title>' TO text.
APPEND ' </head>' TO text.
APPEND ' <body>' TO text.
APPEND ' <p align="center">' TO text.
APPEND ' Corpo do e-mail' TO text.
APPEND ' </p>' TO text.
APPEND ' <br />' TO text.
APPEND ' Em HTML' TO text.
APPEND ' </body>' TO text.
APPEND '</html>' TO text.
document = cl_document_bcs=>create_document(
i_type = 'HTM'
i_text = text
i_subject = 'Assunto E-MAIL' ).
send_request->set_document( document ).
sender = cl_cam_address_bcs=>create_internet_address(
'email@de.com.br' ).
recipient = cl_cam_address_bcs=>create_internet_address(
'email@para.com.br' ).
send_request->set_sender( sender ).
send_request->add_recipient(
EXPORTING
i_recipient = recipient
i_express = 'X' ).
send_request->send(
EXPORTING
i_with_error_screen = 'X'
RECEIVING
result = sent_to_all ).
IF sent_to_all = 'X'.
MESSAGE 'E-mail enviado com sucesso' TYPE 'I'.
ENDIF.
COMMIT WORK.
CATCH cx_bcs INTO bcs_exception.
MESSAGE bcs_exception->error_type TYPE 'E'.
ENDTRY.