Hi Vishnu.
It is always better to use class CL_DOCUMENT_BCS for sending mails using the attatchment.
Please follow the below Code :
*************------------------------------------------------------------------------------------------------------------
CLASS cl_bcs DEFINITION LOAD.
DATA: lo_send_request TYPE REF TO cl_bcs
,lo_document TYPE REF TO cl_document_bcs
,lo_sender TYPE REF TO if_sender_bcs
,lo_recipient TYPE REF TO if_recipient_bcs ,lt_message_body TYPE bcsy_text
,lx_document_bcs TYPE REF TO cx_document_bcs
,lv_send TYPE ad_smtpadr VALUE 'xyz@gmail.com'
,lv_sent_to_all TYPE os_boolean .
"create send request
lo_send_request = cl_bcs=>create_persistent( ).
"create message body and subject
APPEND 'Dear Vendor,' TO lt_message_body.
APPEND INITIAL LINE to lt_message_body.
APPEND 'Please fill the attached .' TO lt_message_body.
APPEND INITIAL LINE to lt_message_body.
APPEND 'Thank You,' TO lt_message_body.
"put your text into the document
lo_document = cl_document_bcs=>create_document(
i_type = 'RAW'
i_text = lt_message_body
i_subject = 'Vendor Payment Form' ).
TRY.
lo_document->add_attachment(
EXPORTING
i_attachment_type = 'PDF'
i_attachment_subject = 'Form'
i_att_content_hex = lt_att_content_hex ).
CATCH cx_document_bcs INTO lx_document_bcs.
ENDTRY.
* Add attachment
* Pass the document to send request
lo_send_request->set_document( lo_document ).
"Create sender
lo_sender = cl_cam_address_bcs=>create_internet_address( l_send ).
"Set sender
lo_send_request->set_sender( lo_sender ).
"Create recipient
lo_recipient = cl_sapuser_bcs=>create( sy-uname ).
*Set recipient
lo_send_request->add_recipient(
EXPORTING
i_recipient = lo_recipient i_express = 'X' ).
lo_send_request->add_recipient( lo_recipient ).
* Send email
lo_send_request->send(
EXPORTING
i_with_error_screen = 'X'
RECEIVING
result = lv_sent_to_all ).
COMMIT WORK.
*************-------------------------------------------------------------------------------------------------------------
Regards,
Sachin