Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Error in HTML Format

Former Member
0 Likes
725

Hi Experts,

                    Am tryng to send mail using cl_bcs by reading my text from SO10  but my errors is am unable to see my data in sost.....when i send mail in HTM format, if i send mail in RAW for am able to see my data in SOST....please check my code n let me knw the solution..

DATA: l_send_request TYPE REF TO cl_bcs,         " Send request

       l_body      TYPE bcsy_text,                " Mail body

       l_attach    TYPE bcsy_text,                " Attachment

       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

       c_tab       TYPE abap_char1  VALUE

                        cl_abap_char_utilities=>horizontal_tab,

       l_lines     TYPE i,                        " Lines count

       l_email     TYPE ad_smtpadr,               " Email ID

       l_extension TYPE soodk-objtp VALUE 'OTF'" TXT format

DATA  : t_body  TYPE soli_tab.

DATA  : t_lines TYPE TABLE OF tline.

DATA  : x_lines TYPE tline.

DATA :v_bcs_exception   TYPE REF TO cx_document_bcs,   " BCS Exception

        v_send_exception  TYPE REF TO cx_send_req_bcs,   " E-Mail sending Exception

        v_addr_exception  TYPE REF TO cx_address_bcs.

  DATA v_message TYPE  string.

*wa_text  = 'Contents'.

*APPEND wa_text  TO l_body.

*CLEAR wa_text .

CALL FUNCTION 'READ_TEXT'

   EXPORTING

*   CLIENT   = SY-MANDT

     id       = 'ST'

     language = sy-langu

     name     = 'ZCRM_POST_SALES'

     object   = 'TEXT'

   TABLES

     lines    = t_lines.

LOOP AT t_lines INTO x_lines WHERE tdformat NE '/*'.

   APPEND x_lines-tdline TO t_body.

ENDLOOP.

TRY.

     l_send_request = cl_bcs=>create_persistent( ).

*craete document for mail body

     l_document = cl_document_bcs=>create_document(

                  i_type    = 'HTM'

                  i_importance  = '5'

                  i_text    t_body

                  i_length  = '100'

                  i_subject = 'Testing Mail Body' ).

*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 = 's.a.m@gmil.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 = ' '.

*trigger e-mail immediately

     l_send_request->set_send_immediately( 'X' ).

*send mail

     CALL METHOD l_send_request->send( ).

   CATCH cx_document_bcs INTO v_bcs_exception.

     v_message = v_bcs_exception->get_text( ).

     MESSAGE v_message TYPE 'S'.

   CATCH cx_send_req_bcs INTO v_send_exception.

     v_message = v_send_exception->get_text( ).

     MESSAGE v_message TYPE 'S'.

   CATCH cx_address_bcs  INTO v_addr_exception.

     v_message = v_addr_exception->get_text( ).

     MESSAGE v_message TYPE 'S'.

ENDTRY.

COMMIT WORK.

1 REPLY 1
Read only

Former Member
0 Likes
511

hi Syed

It seems your type of the mail is not corret.

DATA: int_html    TYPE TABLE OF w3html,

      wf_html     LIKE LINE OF int_html.

cl_document_bcs=>create_document(

      i_type = 'HTM'

      i_text = int_html

      i_length = conlengths

      i_subject = wl_subject ).

or try this:

Data: result_content type string.

*refresh text .

clear result_content .

*The body message

concatenate

'<p><font color="#000080">This is the first line in the email body</font></p>'

'<p><font color="#000080">Second line </font></p>'

'<p><font color="#000080">third line and thank you. </font></p>'

into result_content .

conlength = strlen( result_content ) .

conlengths = conlength .

call function 'SCMS_STRING_TO_FTEXT'

exporting

  text      = result_content

tables

  ftext_tab = text.

try.

  clear send_request .

  send_request = cl_bcs=>create_persistent( ).

  clear document .

  document = cl_document_bcs=>create_document(

  i_type    = 'HTM'

  i_text    = text

  i_length  = conlengths

  i_subject = subject ).

Regards,

Archer