Skip to Content

HTML format not working in email sent by fm SO_NEW_DOCUMENT_ATT_SEND_API1


Hi,

Within an email I am trying to display a list in the table format using the HTML code.In the SOST transaction the format is perfect but when delivered to the user the table format is not displayed in the outlook.

Function module SO_NEW_DOCUMENT_ATT_SEND_API1 is used and the document type is set to HTML format

ls_pack_lst-doc_type = 'HTML'.
APPEND ls_pack_lst TO lt_pack_lst.

Below you can find the screenshots for the format in SOST and outlook, please help me out in fixing this issue...

SOST format

Outlook format

Thanks in advance,

Manoj

SOST.JPG (53.6 kB)
email.JPG (32.1 kB)
Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Posted on Dec 04, 2014 at 01:03 PM

    Hi,

    Remove HTML write as 'HTM'.

    ls_pack_lst-doc_type = 'HTM'.

    hope help to you.

    Regards,

    Rajesh K

    Add a comment
    10|10000 characters needed characters exceeded

    • IF ls_t024d-usrkey IS NOT INITIAL.
      lt_mailrec-receiver = ls_t024d-usrkey.

      lt_mailrec-rec_type = 'U'. "MK 21112014

      lt_mailrec-express = 'X'.

      APPEND lt_mailrec.

      ELSE.

      WRITE text-029.

      ENDIF.



      *Selection screen email id's

      IF p_empf1 IS NOT INITIAL.

      lt_mailrec-receiver = p_empf1.

      lt_mailrec-rec_type = 'U'.

      lt_mailrec-express = 'X'.

      APPEND lt_mailrec.

      ENDIF.

      IF p_empf2 IS NOT INITIAL.

      lt_mailrec-receiver = p_empf2.

      lt_mailrec-rec_type = 'U'.

      lt_mailrec-express = 'X'.

      APPEND lt_mailrec.

      ENDIF.



      IF lt_mailrec[] IS NOT INITIAL.



      * document data

      ls_maildata-obj_name = text-001.

      ls_maildata-obj_descr = text-001.

      ls_maildata-obj_langu = gv_spras.



      * HTML begin

      lt_mailtxt-line = '<html> <body>'.

      APPEND lt_mailtxt.



      CLEAR lt_mailtxt.

      CONCATENATE '<p>' text-002 ',' '</p>' INTO lt_mailtxt-line.

      APPEND lt_mailtxt.



      CLEAR lt_mailtxt.

      lt_mailtxt-line = '<p></p>'.

      APPEND lt_mailtxt.



      IF s_datum-high IS NOT INITIAL.

      CONCATENATE '<p>' text-026 gv_datum_char text-027 gv_datum_char2 text-011 '</p>' INTO lt_mailtxt-line SEPARATED BY space.

      ELSE.

      CONCATENATE '<p>' text-003 gv_datum_char text-011 '</p>' INTO lt_mailtxt-line SEPARATED BY space.

      ENDIF.

      APPEND lt_mailtxt.



      CLEAR lt_mailtxt.

      lt_mailtxt-line = '<p></p>'.

      APPEND lt_mailtxt.



      CLEAR lt_mailtxt.

      lt_mailtxt-line = '<head><style>table, th, td {border: 1px solid black; border-collapse: collapse;}</style></head>'.

      APPEND lt_mailtxt.



      * Field Labels

      CLEAR lt_mailtxt.

      lt_mailtxt-line = '<TR><th bgcolor="wheat">Material</font></th>'.

      APPEND lt_mailtxt.



      CLEAR lt_mailtxt.

      lt_mailtxt-line = '<th bgcolor="wheat">Material beschreibung</th>'.

      APPEND lt_mailtxt.



      CLEAR lt_mailtxt.

      lt_mailtxt-line = '<th bgcolor="wheat">UOM</th>'.

      APPEND lt_mailtxt.



      CLEAR lt_mailtxt.

      lt_mailtxt-line = '<th bgcolor="wheat">Kontrakt</th>'.

      APPEND lt_mailtxt.



      CLEAR lt_mailtxt.

      lt_mailtxt-line = '<th bgcolor="wheat">Kontraktmenge</th>'.

      APPEND lt_mailtxt.



      CLEAR lt_mailtxt.

      lt_mailtxt-line = '<th bgcolor="wheat">Wareneingang</th>'.

      APPEND lt_mailtxt.



      CLEAR lt_mailtxt.

      lt_mailtxt-line = '<th bgcolor="wheat">Differenzmenge</th>'.

      APPEND lt_mailtxt .



      CLEAR lt_mailtxt.

      lt_mailtxt-line = '<th bgcolor="wheat">Differenz in %</th></tr>'.

      APPEND lt_mailtxt .



      * Item data

      LOOP AT gt_mailtab INTO ls_mailtab.



      CLEAR lv_matnr.

      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'

      EXPORTING

      input = ls_mailtab-matnr

      IMPORTING

      output = lv_matnr.



      CLEAR lt_mailtxt.

      CONCATENATE '<tr style="background-color:#eeeeee"><td>' lv_matnr '</td>' INTO lt_mailtxt-line.

      APPEND lt_mailtxt .



      CLEAR lt_mailtxt.

      CONCATENATE '<td>' ls_mailtab-maktx(22) '</td> ' INTO lt_mailtxt-line.

      APPEND lt_mailtxt .



      CLEAR lt_mailtxt.

      CONCATENATE '<td>' ls_mailtab-meins '</td> ' INTO lt_mailtxt-line.

      APPEND lt_mailtxt .



      CLEAR lt_mailtxt.

      CONCATENATE '<td>' ls_mailtab-ebeln '</td> ' INTO lt_mailtxt-line.

      APPEND lt_mailtxt .



      CLEAR lt_mailtxt.

      CONCATENATE '<td>' ls_mailtab-ktmng '</td> ' INTO lt_mailtxt-line.

      APPEND lt_mailtxt .



      CLEAR lt_mailtxt.

      CONCATENATE '<td>' ls_mailtab-menge '</td> ' INTO lt_mailtxt-line.

      APPEND lt_mailtxt .



      CLEAR lt_mailtxt.

      CONCATENATE '<td>' ls_mailtab-diffm '</td> ' INTO lt_mailtxt-line.

      APPEND lt_mailtxt .



      CLEAR lt_mailtxt.

      CONCATENATE '<td>' ls_mailtab-diffp '</td></tr>' INTO lt_mailtxt-line.

      APPEND lt_mailtxt .



      CLEAR ls_mailtab.

      ENDLOOP.



      CLEAR lt_mailtxt.

      lt_mailtxt-line = '</table>'.

      APPEND lt_mailtxt.



      CLEAR lt_mailtxt.

      lt_mailtxt-line = '<p></p>'.

      APPEND lt_mailtxt.



      CLEAR lt_mailtxt.

      CONCATENATE '<p>' text-008 gv_ueber_char text-009 '</p>' INTO lt_mailtxt-line SEPARATED BY space.

      APPEND lt_mailtxt.



      CLEAR lt_mailtxt.

      lt_mailtxt-line = '<p></p>'.

      APPEND lt_mailtxt.



      CLEAR lt_mailtxt.

      CONCATENATE '<p>' text-007 '</p>' INTO lt_mailtxt-line.

      APPEND lt_mailtxt.





      *---Benutzerdaten holen und Abschlußgruß anhängen

      CALL FUNCTION 'BAPI_USER_GET_DETAIL'

      EXPORTING

      username = sy-uname

      IMPORTING

      address = ls_addr

      TABLES

      return = lt_add_return.



      CLEAR lt_mailtxt.

      TRANSLATE ls_addr-firstname TO UPPER CASE.

      TRANSLATE ls_addr-lastname TO UPPER CASE.

      CONCATENATE '<p>' ls_addr-firstname ls_addr-lastname '</p>' INTO lt_mailtxt-line SEPARATED BY space.

      APPEND lt_mailtxt.



      * HTML close

      CLEAR lt_mailtxt.

      lt_mailtxt-line = '</body> </html>'.

      APPEND lt_mailtxt.



      * Document data

      DESCRIBE TABLE lt_mailtxt LINES ls_lines.



      * Packing data

      CLEAR ls_pack_lst-transf_bin.

      ls_pack_lst-head_start = 1.

      ls_pack_lst-head_num = 0.

      ls_pack_lst-body_start = 1.

      ls_pack_lst-body_num = ls_lines.

      ls_pack_lst-doc_type = 'HTM'.

      APPEND ls_pack_lst TO lt_pack_lst.

      CLEAR ls_pack_lst.



      * Send Mail

      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

      EXPORTING

      document_data = ls_maildata

      put_in_outbox = 'X'

      commit_work = 'X'

      TABLES

      packing_list = lt_pack_lst

      * OBJECT_HEADER = LT_OBJHEAD

      contents_txt = lt_mailtxt

      receivers = lt_mailrec

      EXCEPTIONS

      too_many_receivers = 1

      document_not_sent = 2

      document_type_not_exist = 3

      operation_no_authorization = 4

      parameter_error = 5

      x_error = 6

      enqueue_error = 7

      OTHERS = 8.

      Thanks,

      Manoj

  • author's profile photo Former Member
    Former Member
    Posted on Dec 04, 2014 at 01:08 PM
    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 09, 2014 at 02:10 PM

    Is the HTML format compatible with Outlook.... ?

    Because the same mail when delivered to my personal mail box, the format is perfect. I face this issue only with outlook

    Thanks,

    Manoj

    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.