

try.
data(msg) = new cl_bcs_message( ).
msg->set_subject( 'My test email' ).
msg->add_recipient(
exporting
iv_address = 'This email address is being protected from spambots. You need JavaScript enabled to view it.'
* iv_commtype = iv_commtype " Communication Type
iv_visible_name = 'WRITE Yours' " Display Name of an Address
* iv_copy = iv_copy " Copy Recipients (None, CC, BCC)
* iv_fax_country = iv_fax_country " Country for Telephone/Fax Number
).
msg->set_sender(
exporting
iv_address = 'This email address is being protected from spambots. You need JavaScript enabled to view it.' " Communication Address (for INT, FAX, SMS, and so on)
* iv_commtype = iv_commtype " Communication Type
iv_visible_name = 'Do not reply ' " Display Name of an Address
* iv_fax_country = iv_fax_country " Country for Telephone/Fax Number
).
msg->set_main_doc(
exporting
iv_contents_txt = |<html><head></head><body><br/><b>TEST MESSAGE</b><br/><br/>|
&& |sample from <a href='http://ABAPblog.com'>ABAPblog.com</a></body></html>|
* iv_contents_bin = iv_contents_bin " Main Document, First Body Part (Binary)
iv_doctype = 'htm' " Document Category
* iv_codepage = iv_codepage " Character Set of a Document
).
msg->set_send_immediately( abap_true ).
msg->send( ).
catch cx_bcs_send into data(ex).
message ex->get_text( ) type 'E'.
endtry.