cancel
Showing results for 
Search instead for 
Did you mean: 

How to send an email without any attachment with a simple message???

Former Member
0 Kudos

Hello ALL,

I have a requirement of sending an email on click of a button. I have navigated through the class CL_BCS,

but I am anable to understand certain things. First is : WHAT IS THE USE OF CREATE_PERSISTENT ???

Second: which method would send an email?

How do I add the sender's email id and receipent's email id?

Accepted Solutions (1)

Accepted Solutions (1)

shahid
Product and Topic Expert
Product and Topic Expert
0 Kudos

I believe create persistent method will create instance of CL_BCS and provide the instance of send request

Former Member
0 Kudos

Thnx !!...

Got it!!.

Answers (2)

Answers (2)

shahid
Product and Topic Expert
Product and Topic Expert
0 Kudos

you can ignore the add attachment method in the code

shahid
Product and Topic Expert
Product and Topic Expert
0 Kudos

TRY.

  • create persistent send request

lp_send_request = cl_bcs=>create_persistent( ).

  • Get the text

IF iv_stxt IS NOT INITIAL.

CALL METHOD zfi_flexgl_common=>read_text

EXPORTING

iv_stxt = iv_stxt

IMPORTING

et_tline = lt_tline

ev_failed = ev_failed.

LOOP AT lt_tline INTO ls_tline.

APPEND ls_tline-tdline TO lt_text.

ENDLOOP.

ENDIF.

  • create and set document

  • create document from internal table with text

lp_document = cl_document_bcs=>create_document(

i_type = iv_format_type "'XLS' "HTM'

i_text = lt_text

i_subject = iv_msg_subj ).

IF it_attach IS NOT INITIAL.

  • Add attachment

  • DATA: l_size TYPE sood-objlen, " Size of Attachment

  • l_lines TYPE i. " Lines count

*

  • l_lines = LINES( it_attach ).

  • l_size = l_lines * 255.

CALL METHOD lp_document->add_attachment

EXPORTING

i_attachment_type = 'RAW'

i_attachment_subject = 'My attachment'

  • i_attachment_size = l_size

i_att_content_text = it_attach.

ENDIF.

  • add document to send request

CALL METHOD lp_send_request->set_document( lp_document ).

  • Sender addess

*l_sender = cl_sapuser_bcs=>create( sy-uname ).

*call method l_send_request->set_sender

  • exporting

  • i_sender = l_sender.

  • LOOP AT it_rec INTO ls_rec.

lv_receiver = iv_rec.

TRY.

CALL METHOD cl_cam_address_bcs=>create_internet_address

EXPORTING

i_address_string = lv_receiver

RECEIVING

result = lp_recipient.

CATCH cx_address_bcs .

ENDTRY.

CALL METHOD lp_send_request->add_recipient

EXPORTING

i_recipient = lp_recipient

i_blind_copy = abap_true

i_express = abap_true.

  • ENDLOOP.

IF sy-subrc <> 0.

ev_failed = abap_true.

EXIT.

ENDIF.

  • ---------- send document ---------------------------------------

CALL METHOD lp_send_request->send(

RECEIVING

result = lv_flag ).

CATCH cx_send_req_bcs.

ev_failed = abap_true.

CATCH cx_document_bcs.

ev_failed = abap_true.

ENDTRY.

Former Member
0 Kudos

@ SSM :...Thnx for your reply, but I mentioned that I just want to send an email, without any attachments.

Secondly, What is the use of CREATE_PERSISTENT??