cancel
Showing results for 
Search instead for 
Did you mean: 

How to place a Logo, Picture ..etc in the main body of an email.

Former Member
0 Kudos

My requirement is to send an email having a logo as the header. The logo must be placed in the main body of the email and NOT as an attachment.

I have tried out the following but it gives garbage:

REPORT  ztest_pratik01.

***********************************************************************

  • INTERNAL TABLES

***********************************************************************

DATA:

      i_objpack   TYPE STANDARD TABLE OF sopcklsti1,

      i_objtext   TYPE STANDARD TABLE OF solisti1,

      i_objbin    TYPE STANDARD TABLE OF solisti1,

      i_hex       TYPE STANDARD TABLE OF solix,

      i_receivers TYPE STANDARD TABLE OF somlreci1.

***********************************************************************

  • WORK AREAS

***********************************************************************

DATA: wa_email_doc TYPE sodocchgi1,

      wa_objpack   TYPE sopcklsti1,

      wa_objtext   TYPE solisti1,

      wa_hex       TYPE solix,

      wa_receivers TYPE somlreci1.

***********************************************************************

  • CONSTANTS

***********************************************************************

CONSTANTS: c_x     TYPE flag   VALUE 'X',

           c_u     TYPE char1  VALUE 'U'.

DATA: v_body TYPE i.

***********************************************************************

  • START-OF-SELECTION

***********************************************************************

START-OF-SELECTION.

  PERFORM sub_get_logo.

***********************************************************************

  • END-OF-SELECTION

***********************************************************************

END-OF-SELECTION.

  wa_email_doc-obj_name = 'TEST Mail'.

  "Mail Subject

  wa_email_doc-obj_descr

  = 'TEST'.

  v_body = LINES( i_hex ).

    • Creating the entry for the compressed document

*--(1): Creating entry for the Main Mail body text in itab i_objtext

wa_objpack-transf_bin = 'X'.

  " Starting index(row) For header information in the itab i_objpack

  wa_objpack-head_start = 1.

  " No of lines for the header information in itab i_objpack

  wa_objpack-head_num   = 1.

  " The row(index) of the itab i_objtext from where the Mail Body starts

  wa_objpack-body_start = 1.  "Skipped the first Line

  " The number of lines in the Mail body

  wa_objpack-body_num   = v_body.  "We have two lines from the 2nd row

  " Document type. There are also whole lot of other options

  wa_objpack-doc_type   = 'RAW'.

  wa_objpack-obj_name   = 'LOGO.BMP'.

  wa_objpack-obj_descr  = 'MAIL BODY'.

  wa_objpack-obj_langu  = ' '.

  " In this case one can skip this. Normally ist calculated as

  " no of linex * 255

  wa_objpack-doc_size = v_body * 255.

  APPEND wa_objpack TO i_objpack.

  CLEAR wa_objpack.

*Building the recepient list

    • Receipient information

  wa_receivers-receiver = sy-uname.

  wa_receivers-rec_type = 'B'. "To SAP Inbox

  APPEND wa_receivers TO i_receivers.

  CLEAR wa_receivers.

  wa_receivers-receiver = mail id.

  wa_receivers-rec_type = c_u.

  APPEND wa_receivers TO i_receivers.

  CLEAR wa_receivers.

  • Finally Send the Document

  CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

    EXPORTING

      document_data              = wa_email_doc

      put_in_outbox              = 'X'

      commit_work                = 'X'

    TABLES

      packing_list               = i_objpack

      contents_bin               = i_objbin

      contents_txt               = i_objtext

      contents_hex               = i_hex

      receivers                  = i_receivers

    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.

  IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  •         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

  ENDIF.

&----


*&      Form  SUB_GET_LOGO

&----


  •       text

----


  • -->  p1        text

  • <--  p2        text

----


FORM sub_get_logo .

  DATA: graphic_url(255),

        graphic_refresh(1).

  DATA: graphic_size TYPE i.

  DATA: l_graphic_xstr TYPE xstring,

      l_graphic_conv TYPE i,

      l_graphic_offs TYPE i.

  DATA: BEGIN OF graphic_table OCCURS 0,

        line(255) TYPE x,

      END OF graphic_table.

  CLEAR: graphic_url,

         graphic_table[].

  CALL METHOD cl_ssf_xsf_utilities=>get_bds_graphic_as_bmp

    EXPORTING

      p_object  = 'GRAPHICS'

      p_name    = 'Z_LOGO'

      p_id      = 'BMAP'

      p_btype   = 'BMON'

    RECEIVING

      p_bmp     = l_graphic_xstr

    EXCEPTIONS

      not_found = 1

      OTHERS    = 2.

  •   if sy-subrc = 1.

  •     message e287 with g_stxbitmaps-tdname.

  •   elseif sy-subrc <> 0.

  •     message id sy-msgid type sy-msgty number sy-msgno

  •             with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

  •     exit.

  •   endif.

  graphic_size = XSTRLEN( l_graphic_xstr ).

  CHECK graphic_size > 0.

  l_graphic_conv = graphic_size.

  l_graphic_offs = 0.

  WHILE l_graphic_conv > 255.

    graphic_table-line = l_graphic_xstr+l_graphic_offs(255).

    APPEND graphic_table.

    l_graphic_offs = l_graphic_offs + 255.

    l_graphic_conv = l_graphic_conv - 255.

  ENDWHILE.

  graphic_table-line = l_graphic_xstr+l_graphic_offs(l_graphic_conv).

  APPEND graphic_table.

  LOOP AT graphic_table.

    wa_hex = graphic_table.

    APPEND wa_hex TO i_hex.

  ENDLOOP.

ENDFORM.                    " SUB_GET_LOGO

Any Ideas how to do the same???

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi ,

I advice you to raise a OSS Note so that SAP Can suggest what needs to be done in this case .

Hope my suggestion is helpful.

Thanks & Regards

Pradeep Akula .

Answers (0)