REPORT ZZXTEST111.
data: l_send_request type ref to cl_bcs, " Send request
l_body type bcsy_text, " Mail body
l_success type bcsy_text, " Atchmnt for success
l_error type bcsy_text, " Atchmnt for error
wa_text type soli, " Work area for attach
l_document type ref to cl_document_bcs, " Mail body
l_sender type ref to if_sender_bcs, " Sender address
l_recipient type ref to if_recipient_bcs, " Recipient
l_size type sood-objlen, " Size of Attachment
l_lines type i, " Lines count
l_email type ad_smtpadr, " Email ID
l_extension type soodk-objtp value 'RAW'. " TXT format
* Prepare mail bidy
append 'Send multiple file as attachment of a Email.' to l_body.
append space to l_body.
* Preparing contents of attachment with Change Log
* Header line
wa_text-line+0 = 'First column'.
wa_text-line+20 = 'Second column'.
wa_text-line+40 = 'Third column'.
wa_text-line+60 = 'Fourth column'.
wa_text-line+80 = 'Fifth column'.
wa_text-line+100 = 'Sixth column'.
wa_text-line+120 = 'Seventh column'.
wa_text-line+140 = 'Eighth column'.
append wa_text to l_success.
append wa_text to l_error.
clear : wa_text.
* Populate the data part
wa_text-line+0 = '111111111'.
wa_text-line+20 = '222222222'.
wa_text-line+40 = '333333333'.
wa_text-line+60 = '333333333'.
wa_text-line+80 = '444444444'.
wa_text-line+100 = '555555555'.
wa_text-line+120 = '666666666'.
wa_text-line+140 = '777777777'.
append wa_text to l_success.
clear : wa_text.
wa_text-line+0 = 'aaaaaaaaa'.
wa_text-line+20 = 'bbbbbbbbb'.
wa_text-line+40 = 'ccccccccc'.
wa_text-line+60 = 'ddddddddd'.
wa_text-line+80 = 'eeeeeeeee'.
wa_text-line+100 = 'fffffffff'.
wa_text-line+120 = 'ggggggggg'.
wa_text-line+140 = 'hhhhhhhhh'.
append wa_text to l_error.
clear : wa_text.
* Creates persistent send request
l_send_request = cl_bcs=>create_persistent( ).
* Craete document for mail body
l_document = cl_document_bcs=>create_document(
i_type = 'RAW'
i_text = l_body " Mail body
i_subject = 'Mail send as attachment' ).
* Attachment for success records
l_lines = lines( l_success ).
l_size = l_lines * 255.
* Add attchment
call method l_document->add_attachment
exporting
i_attachment_type = l_extension
i_attachment_subject = 'Success'
i_attachment_size = l_size
i_att_content_text = l_success. " Attachment for success record
* Attachment for error records
l_lines = lines( l_error ).
l_size = l_lines * 255.
* Add attchment
call method l_document->add_attachment
exporting
i_attachment_type = l_extension
i_attachment_subject = 'Error'
i_attachment_size = l_size
i_att_content_text = l_error. " Attachment for error record
* Add the document to send request
call method l_send_request->set_document( l_document ).
* Sender addess
l_sender = cl_sapuser_bcs=>create( sy-uname ).
call method l_send_request->set_sender
exporting
i_sender = l_sender.
* Recipient address
l_email = 'XXXXXXXX@yahoo.com'.
l_recipient = cl_cam_address_bcs=>create_internet_address( l_email ).
* Add recipient address to send request
call method l_send_request->add_recipient
exporting
i_recipient = l_recipient
i_express = 'X'
i_copy = ' '
i_blind_copy = ' '
i_no_forward = ' '.
*l_email = 'myname@gmail.com'.
*l_recipient = cl_cam_address_bcs=>create_internet_address( l_email ).
** Add recipient address to send request
*call method l_send_request->add_recipient
* exporting
* i_recipient = l_recipient
* i_express = 'X'
* i_copy = ' '
* i_blind_copy = ' '
* i_no_forward = ' '.
* E-Mail is placed into queue for sending. In case of very important alerts
* use the following parameter to initiate an 'immediate sending'; but notice that
* this will trigger a dedicated send process for every single message - which is
* very costly for system performance
* l_send_request->set_send_immediately( 'X' ). "uncomment for immediate sending
* Send mail
call method l_send_request->send( ).
commit work.
data: l_send_request type ref to cl_bcs, " Send request
l_body type bcsy_text, " Mail body
l_success type bcsy_text, " Atchmnt for success
l_error type bcsy_text, " Atchmnt for error
wa_text type soli, " Work area for attach
l_document type ref to cl_document_bcs, " Mail body
l_sender type ref to if_sender_bcs, " Sender address
l_recipient type ref to if_recipient_bcs, " Recipient
l_size type sood-objlen, " Size of Attachment
l_lines type i, " Lines count
l_email type ad_smtpadr, " Email ID
l_extension type soodk-objtp value 'RAW'. " TXT format
* Prepare mail bidy
append 'Send multiple file as attachment of a Email.' to l_body.
append space to l_body.
* Preparing contents of attachment with Change Log
* Header line
wa_text-line+0 = 'First column'.
wa_text-line+20 = 'Second column'.
wa_text-line+40 = 'Third column'.
wa_text-line+60 = 'Fourth column'.
wa_text-line+80 = 'Fifth column'.
wa_text-line+100 = 'Sixth column'.
wa_text-line+120 = 'Seventh column'.
wa_text-line+140 = 'Eighth column'.
append wa_text to l_success.
append wa_text to l_error.
clear : wa_text.
* Populate the data part
wa_text-line+0 = '111111111'.
wa_text-line+20 = '222222222'.
wa_text-line+40 = '333333333'.
wa_text-line+60 = '333333333'.
wa_text-line+80 = '444444444'.
wa_text-line+100 = '555555555'.
wa_text-line+120 = '666666666'.
wa_text-line+140 = '777777777'.
append wa_text to l_success.
clear : wa_text.
wa_text-line+0 = 'aaaaaaaaa'.
wa_text-line+20 = 'bbbbbbbbb'.
wa_text-line+40 = 'ccccccccc'.
wa_text-line+60 = 'ddddddddd'.
wa_text-line+80 = 'eeeeeeeee'.
wa_text-line+100 = 'fffffffff'.
wa_text-line+120 = 'ggggggggg'.
wa_text-line+140 = 'hhhhhhhhh'.
append wa_text to l_error.
clear : wa_text.
* Creates persistent send request
l_send_request = cl_bcs=>create_persistent( ).
* Craete document for mail body
l_document = cl_document_bcs=>create_document(
i_type = 'RAW'
i_text = l_body " Mail body
i_subject = 'Mail send as attachment' ).
* Attachment for success records
l_lines = lines( l_success ).
l_size = l_lines * 255.
* Add attchment
call method l_document->add_attachment
exporting
i_attachment_type = l_extension
i_attachment_subject = 'Success'
i_attachment_size = l_size
i_att_content_text = l_success. " Attachment for success record
* Attachment for error records
l_lines = lines( l_error ).
l_size = l_lines * 255.
* Add attchment
call method l_document->add_attachment
exporting
i_attachment_type = l_extension
i_attachment_subject = 'Error'
i_attachment_size = l_size
i_att_content_text = l_error. " Attachment for error record
* Add the document to send request
call method l_send_request->set_document( l_document ).
* Sender addess
l_sender = cl_sapuser_bcs=>create( sy-uname ).
call method l_send_request->set_sender
exporting
i_sender = l_sender.
* Recipient address
l_email = 'XXXXXXXX@yahoo.com'.
l_recipient = cl_cam_address_bcs=>create_internet_address( l_email ).
* Add recipient address to send request
call method l_send_request->add_recipient
exporting
i_recipient = l_recipient
i_express = 'X'
i_copy = ' '
i_blind_copy = ' '
i_no_forward = ' '.
*l_email = 'myname@gmail.com'.
*l_recipient = cl_cam_address_bcs=>create_internet_address( l_email ).
** Add recipient address to send request
*call method l_send_request->add_recipient
* exporting
* i_recipient = l_recipient
* i_express = 'X'
* i_copy = ' '
* i_blind_copy = ' '
* i_no_forward = ' '.
* E-Mail is placed into queue for sending. In case of very important alerts
* use the following parameter to initiate an 'immediate sending'; but notice that
* this will trigger a dedicated send process for every single message - which is
* very costly for system performance
* l_send_request->set_send_immediately( 'X' ). "uncomment for immediate sending
* Send mail
call method l_send_request->send( ).
commit work.