Skip to Content

send mail using cl_bcs. need text in mail body

Hi friends,

please provide me some solution to send mail with out attachment and the message should only be in mail body.

Code :

 TRY.
*     -------- create persistent send request ------------------------
        send_request = cl_bcs=>create_persistent( ).

*     -------- create and set document -------------------------------
*     create document from internal table with text

        CLEAR lv_const.
        CONCATENATE 'Dear' gs_cust-name1 ',' INTO lv_const SEPARATED BY space.
        APPEND lv_const TO text.

        CLEAR lv_const.
        CONCATENATE 'at' gs_cust-new_date 'planned delivery for you with following items:'
                    INTO lv_const SEPARATED BY space.
        APPEND lv_const TO text.


        l_space = '                                       ' .
        APPEND l_space TO text .
        CLEAR : gs_mat,
                lv_const.
        CLEAR l_quan.
        LOOP AT gt_mat INTO gs_mat WHERE new_date = gs_cust-new_date.
          l_quan = gs_mat-zmeng.
          CONCATENATE gs_mat-matnr gs_mat-maktx l_quan INTO lv_const SEPARATED BY space.
          APPEND lv_const TO text.
          CLEAR :
                  lv_const.
        ENDLOOP.

        l_space = '                                       ' .
        APPEND l_space TO text .
        APPEND 'Please contact with us if you confirm whether above products are' TO text.
        CLEAR lv_const.
        CONCATENATE 'required on' gs_cust-new_date 'with specified quantity.'
                    INTO lv_const SEPARATED BY space .
        APPEND lv_const TO text.
        APPEND 'You can contact with us via e-mail:xxxxxx or via' TO text.
        APPEND 'phone +xxxxxxxxxxxxxx' TO text.
        l_space = '                                       ' .
        APPEND l_space TO text .
        APPEND 'Best regards' TO text.
        APPEND 'Linde Central Logistic Team' TO text.

        lo_document = cl_document_bcs=>create_document(
                        i_type    = 'RAW'
                        i_text    = text
*                        i_length  = '12'
                        i_subject = 'test mail' ).

*     add document to send request
        CALL METHOD send_request->set_document( lo_document ).


*     --------- add recipient (e-mail address) -----------------------
*     create recipient - please replace e-mail address !!!
        recipient = cl_cam_address_bcs=>create_internet_address(
                                          'address' ).

*     add recipient with its respective attributes to send request
        CALL METHOD send_request->add_recipient
          EXPORTING
            i_recipient = recipient
            i_express   = 'X'.


*     ---------- send document ---------------------------------------
          CALL METHOD send_request->send(
            EXPORTING
              i_with_error_screen = 'X'
            RECEIVING
              result              = sent_to_all ).
          COMMIT WORK.

*  Send Immediately
          send_request->set_send_immediately( i_send_immediately = 'X' ).


      CATCH cx_bcs INTO bcs_exception.
        WRITE: text-001.
        WRITE: text-002, bcs_exception->error_type.
        EXIT.

    ENDTRY.

Please provide me the solution if i am missing any thing.

Thanks,

Kat

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Posted on Jun 30, 2011 at 12:52 PM

    thank you for looking into this thread,

    i have configured the in scot.

    currently sending all RAW type as TXT. this has resolved my issues.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.