Skip to Content
0
Jun 12, 2014 at 07:10 AM

how to add our own sender mail id for cl_bcs

948 Views

Hi all,

CONSTANTS:

gc_subject TYPE so_obj_des VALUE 'ABAP Email with CL_BCS',

gc_raw TYPE char03 VALUE 'RAW'.

TRY.

"Create send request

gr_send_request = cl_bcs=>create_persistent( ).

"Email FROM...

gr_sender = cl_sapuser_bcs=>create( sy-uname ).

"Add sender to send request

CALL METHOD gr_send_request->set_sender

EXPORTING

i_sender = gr_sender.

"Email TO...

gv_email = 'frodo.baggins@outlook.com'.

gr_recipient = cl_cam_address_bcs=>create_internet_address( gv_email ).

"Add recipient to send request

CALL METHOD gr_send_request->add_recipient

EXPORTING

i_recipient = gr_recipient

i_express = 'X'.

"Email BODY

APPEND 'Hello world! My first ABAP email!' TO gv_text.

gr_document = cl_document_bcs=>create_document(

i_type = gc_raw

i_text = gv_text

i_length = '12'

i_subject = gc_subject ).

"Add document to send request

CALL METHOD gr_send_request->set_document( gr_document ).

"Send email

CALL METHOD gr_send_request->send(

EXPORTING

i_with_error_screen = 'X'

RECEIVING

result = gv_sent_to_all ).

IF gv_sent_to_all = 'X'.

WRITE 'Email sent!'.

ENDIF.

"Commit to send email

COMMIT WORK.

"Exception handling

CATCH cx_bcs INTO gr_bcs_exception.

WRITE:

'Error!',

'Error type:',

gr_bcs_exception->error_type.

ENDTRY.

1) Im using this method to send email, But my requirement is to create the my own sendor mail id in the above program instead of using the username.

2) I need to increase the subject length from 50 to 100char.