Skip to Content
avatar image
Former Member

font options in mail

Hi,

Am using the function module 'SO_NEW_DOCUMENT_SEND_API1' to send mails.

But inorder to send the mail with different font sizes and font options, i can use HTML code.

But is there any chance that i could send the mails with different font options other than HTML code..

is there any other way..out..

Pls help..

Thanks in adv

Will be rewarded.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Aug 20, 2007 at 11:17 AM

    Email is rule by the RFC (Request For Comment), you could show that email is in brut text, there is no font options.

    To by-pass that, mail-editor use the HTML language.

    So without HTML ... you will not be able to play with font.

    Fred

    Add comment
    10|10000 characters needed characters exceeded

    • I could give you one of my old code, I don't know if the function still work. But maybe you will find what you expected.

      report z_ke_ext_0003 line-size 256
             no standard page heading.
      
      
      
      
      
      *------------------------------- TABLES -------------------------------*
      tables : s076 ,
               usr02 ,
               adr6 .
      
      
      
      
      
      *-------------------------------- DATA --------------------------------*
      data : itab_source   type table of zke_0001 with header line ,
             itab_abs_copa type table of zke_0001 with header line ,
             itab_abs_pic  type table of zke_0001 with header line ,
             itab_diff     type table of zke_0001 with header line ,
             itab_result   type table of w3html   with header line .
      
      data : c_title(50) type c
                          value 'Resultat du control CO-PA PIC'.
      
      
      
      *--------------------------- SELECT OPTIONS ---------------------------*
      selection-screen begin of block b1 with frame title text-001.
        parameters : p_versi type rkeversi
                             obligatory ,
                     p_vers2 type rkeversi
                             obligatory ,
                     p_erkrs type erkrs
                             obligatory ,
                     p_vrgar type rke_vrgar
                             obligatory ,
                     p_werks type werks_d
                             obligatory .
      selection-screen end   of block b1.
      
      selection-screen skip 1.
      
      selection-screen begin of block b2 with frame title text-002.
        select-options : s_perbl for s076-spmon.
      selection-screen end   of block b2.
      
      selection-screen skip 1.
      
      selection-screen begin of block b3 with frame title text-003.
        parameters : p_file radiobutton group g1 ,
                     p_mail radiobutton group g1 .
        select-options : s_bname for usr02-bname no intervals.
      selection-screen end   of block b3.
      
      
      
      
      *-------------------------------- MAIN --------------------------------*
      start-of-selection.
      
      
      * Log the execution.
        call function 'Z_BC_STAT_REPORT'.
      
      * Extract data.
        perform p_extract_data.
      
      * Edit the result.
        perform p_edit_result.
      
      * Create the file in the desktop.
        if p_file eq 'X'.
          perform p_create_file.
        else.
          perform p_create_mail.
        endif.
      
      end-of-selection.
      
      
      
      
      
      
      
      *----------------------------------------------------------------------*
      *   Form P_EXTRACT_DATA.                                               *
      *----------------------------------------------------------------------*
      *   Extract data into three table :                                    *
      *   - ITAB_ABS_COPA   Present in PIC but absent in COPA.               *
      *   - ITAB_ABS_PIC    Present in COPA but absent in PIC.               *
      *   - ITAB_DIFF       Present in both but with different quantity.     *
      *----------------------------------------------------------------------*
      form p_extract_data.
      
      
        types : begin of type_extract ,
                  versi    type rkeversi ,
                  artnr    type artnr ,
                  perbl    type rke_belnr ,
                  werks    type werks_d ,
                  absmg    type rke2_absmg ,
                  absmg_me type meins ,
                  mesh6    type mseh6 ,
                  maktx    type maktx ,
                end   of type_extract .
      
        data : itab_s076 type sorted table of type_extract
                         with unique key versi perbl artnr werks
                         with header line ,
      
               itab_ce2x type sorted table of type_extract
                         with unique key versi perbl artnr werks
                         with header line .
      
        data : v_tabname(10) type c.
      
      
      
      * Extract the data of S076.
        select vrsio pmnux spmon wenux absat basme
               into table itab_s076
               from s076
               where vrsio eq p_vers2
               and   wenux eq p_werks
               and   spmon in s_perbl.
        loop at itab_s076.
          select single mseh6
                 into itab_s076-mesh6
                 from t006a
                 where spras eq sy-langu
                 and   msehi eq itab_s076-absmg_me.
          select single maktx
                 into itab_s076-maktx
                 from makt
                 where matnr eq itab_s076-artnr
                 and   spras eq sy-langu.
          modify itab_s076.
          clear  itab_s076.
        endloop.
      
      
      * Extract the data of CE2x
        concatenate 'CE2'
                    p_erkrs
                    into v_tabname.
        select versi artnr perbl werks absmg001 absmg_me
               into table itab_ce2x
               from (v_tabname)
                where versi eq p_versi
                and   vrgar eq p_vrgar
                and   perbl in s_perbl
                and   werks eq p_werks.
        loop at itab_ce2x.
          select single mseh6
                 into itab_ce2x-mesh6
                 from t006a
                 where spras eq sy-langu
                 and   msehi eq itab_ce2x-absmg_me.
          select single maktx
                 into itab_ce2x-maktx
                 from makt
                 where matnr eq itab_ce2x-artnr
                 and   spras eq sy-langu.
          modify itab_ce2x.
          clear  itab_ce2x.
        endloop.
      
      
      * First step : Present in PIC absent in COPA.
        loop at itab_s076.
          read table itab_ce2x
               with key versi = itab_s076-versi
                        perbl = itab_s076-perbl
                        artnr = itab_s076-artnr
                        werks = itab_s076-werks.
          if sy-subrc ne space.
            move-corresponding itab_s076 to itab_abs_copa.
            move : itab_s076-absmg to itab_abs_copa-z_absmg02 ,
                   itab_s076-versi to itab_abs_copa-vers2 .
            move '   ' to itab_abs_copa-versi.
            append itab_abs_copa.
          endif.
        endloop.
      
      * Second step : Present in COPA absent in PIC.
        loop at itab_ce2x.
          read table itab_s076
               with key versi = itab_ce2x-versi
                        perbl = itab_ce2x-perbl
                        artnr = itab_ce2x-artnr
                        werks = itab_ce2x-werks.
          if sy-subrc ne space.
            move-corresponding itab_ce2x to itab_abs_pic.
            move itab_ce2x-absmg to itab_abs_pic-z_absmg01.
            append itab_abs_pic.
          endif.
        endloop.
      
      * Last step : Quantity different.
        loop at itab_s076.
          read table itab_ce2x
               with key versi = itab_s076-versi
                        perbl = itab_s076-perbl
                        artnr = itab_s076-artnr
                        werks = itab_s076-werks
                        absmg = itab_s076-absmg.
          if sy-subrc ne space.
            read table itab_ce2x
                 with key versi = itab_s076-versi
                          perbl = itab_s076-perbl
                          artnr = itab_s076-artnr
                          werks = itab_s076-werks.
            if sy-subrc eq space.
              move-corresponding itab_s076 to itab_diff.
              move : itab_s076-absmg to itab_diff-z_absmg02 ,
                     itab_ce2x-absmg to itab_diff-z_absmg01 ,
                     itab_ce2x-versi to itab_diff-versi ,
                     itab_s076-versi to itab_diff-vers2.
              append itab_diff.
            endif.
          endif.
        endloop.
      
      
      * Modify the layout.
        loop at itab_abs_copa.
      *   Remove 0 before the article number.
          itab_abs_copa-artnr = itab_abs_copa-artnr+10(8).
      *   Format the period.
          concatenate '0'
                      itab_abs_copa-perbl+4(2)
                      '.'
                      itab_abs_copa-perbl+0(4)
                      into itab_abs_copa-perbl.
      *   Put the COPA version.
          move p_versi to itab_abs_copa-versi.
      *   Record modification.
          modify itab_abs_copa.
        endloop.
      
        loop at itab_abs_pic.
      *   Remove 0 before the article number.
          itab_abs_pic-artnr = itab_abs_pic-artnr+10(8).
      *   Format the period.
          concatenate itab_abs_pic-perbl+4(3)
                      '.'
                      itab_abs_pic-perbl+0(4)
                      into itab_abs_pic-perbl.
      *   Move the PIC version.
          move p_vers2 to itab_abs_pic-vers2.
      *   Record modification.
          modify itab_abs_pic.
        endloop.
      
        loop at itab_diff.
      *   Remove 0 before the article number.
          itab_diff-artnr = itab_diff-artnr+10(8).
      *   Format the period.
          concatenate itab_diff-perbl+4(3)
                      '.'
                      itab_diff-perbl+0(4)
                      into itab_diff-perbl.
      *   Record modification.
          modify itab_diff.
        endloop.
      
      
      
      
      endform.                     " P_EXTRACT_DATA.
      
      
      
      
      
      
      *----------------------------------------------------------------------*
      *   Form P_EDIT_RESULT.                                                *
      *----------------------------------------------------------------------*
      *   Append data into ITAB_RESULT in HTML format.                       *
      *----------------------------------------------------------------------*
      form p_edit_result.
      
      
        data : itab_data         type lvc_t_data ,
               itab_info         type lvc_t_info ,
               itab_html         type table of w3html ,
               v_count(9)        type n ,
               v_title(80)       type c ,
               v_first(1)        type c.
      
      
      * Transform the first step.
        describe table itab_abs_copa lines v_count.
        if v_count gt space.
          itab_source[] = itab_abs_copa[].
          perform p_trans_table tables itab_data
                                       itab_info
                                using  'ZKE_0001'.
           call function 'LVC_ALV_CONVERT_TO_HTML'
            exporting
              it_data                       = itab_data
              it_info                       = itab_info
              i_file_dialog                 = ' '
            importing
              et_html                       = itab_html.
          move : 'Articles présents dans le PIC mais absents de CO-PA' to
                 v_title ,
                 'F' to v_first.
          perform p_clean_html tables itab_html
                               using  v_title
                                      v_first.
          loop at itab_html into itab_result.
            append itab_result.
          endloop.
        endif.
      
      * Transform the second step.
        describe table itab_abs_pic lines v_count.
        if v_count gt space.
          refresh : itab_source, itab_data, itab_info.
          itab_source[] = itab_abs_pic[].
          perform p_trans_table tables itab_data
                                       itab_info
                                using  'ZKE_0001'.
           call function 'LVC_ALV_CONVERT_TO_HTML'
            exporting
              it_data                       = itab_data
              it_info                       = itab_info
              i_file_dialog                 = ' '
            importing
              et_html                       = itab_html.
          move : 'Articles présents dans CO-PA mais absents du PIC' to
                 v_title ,
                 ' ' to v_first.
          perform p_clean_html tables itab_html
                               using v_title
                                     v_first.
          loop at itab_html into itab_result.
            append itab_result.
          endloop.
        endif.
      
      * Transform the first step.
        describe table itab_diff lines v_count.
        if v_count gt space.
          refresh : itab_source, itab_data, itab_info.
          itab_source[] = itab_diff[].
          perform p_trans_table tables itab_data
                                       itab_info
                                using  'ZKE_0001'.
           call function 'LVC_ALV_CONVERT_TO_HTML'
            exporting
              it_data                       = itab_data
              it_info                       = itab_info
              i_file_dialog                 = ' '
            importing
              et_html                       = itab_html.
          concatenate 'Articles présent dans les deux budgets mais avec des'
                      'quantités différentes.'
                      into v_title.
          move 'L' to v_first.
          perform p_clean_html tables itab_html
                               using v_title
                                     v_first.
          loop at itab_html into itab_result.
            append itab_result.
          endloop.
        endif.
      
      
      endform.                     " P_EDIT_RESULT.
      
      
      
      
      
      
      *----------------------------------------------------------------------*
      *   Form P_CREATE_FILE.                                                *
      *----------------------------------------------------------------------*
      *   Create the file in the user desktop.                               *
      *----------------------------------------------------------------------*
      form p_create_file.
      
      
        call function 'DOWNLOAD'
          tables
            data_tab                      = itab_result
          exceptions
            invalid_filesize              = 1
            invalid_table_width           = 2
            invalid_type                  = 3
            no_batch                      = 4
            unknown_error                 = 5
            gui_refuse_filetransfer       = 6
            customer_error                = 7
            others                        = 8
                  .
        if sy-subrc ne space.
          write : 'Can''t write file !'.
          stop.
        endif.
      
      
      endform.                     " P_CREATE_FILE.
      
      
      
      
      
      
      
      
      
      
      *----------------------------------------------------------------------*
      *   Form P_TRANS_TABLE.                                                *
      *----------------------------------------------------------------------*
      *   Transformation of the internal table ITAB_DATA in two tables       *
      *   usable by the HTML convertion function.                            *
      *----------------------------------------------------------------------*
      form p_trans_table tables itab_data type lvc_t_data
                                itab_info type lvc_t_info
                         using  v_name type tabname.
      
      
        data : itab_fieldcatalog   type lvc_t_fcat ,
               struct_fieldcatalog type lvc_s_fcat ,
               struct_info         type lvc_s_info ,
               struct_data         type lvc_s_data ,
               v_count_row(6)      type n ,
               v_count_col(6)      type n ,
               v_max_row(6)        type n ,
               v_max_col(6)        type n ,
               v_field(30)         type c .
      
        data : begin of itab_tmp_field occurs 10 ,
                 line(100) type c ,
               end   of itab_tmp_field.
      
        field-symbols : <field> type any .
      
      
      
      * Get the fieldcatalog of the structure.
        call function 'LVC_FIELDCATALOG_MERGE'
             exporting
                  i_structure_name   = v_name
                  i_bypassing_buffer = 'X'
             changing
                  ct_fieldcat        = itab_fieldcatalog.
      
      * Transform the form fieldcatalog to struct_info.
        loop at itab_fieldcatalog into struct_fieldcatalog.
          move-corresponding struct_fieldcatalog to struct_info.
          move : struct_fieldcatalog-scrtext_l to struct_info-text ,
                 struct_fieldcatalog-scrtext_m to struct_info-text_m ,
                 struct_fieldcatalog-scrtext_s to struct_info-text_s ,
                 struct_fieldcatalog-reptext   to struct_info-tooltip ,
                 struct_fieldcatalog-col_pos   to struct_info-col_id .
          append struct_info to itab_info.
        endloop.
      
      
      
      * Get the number of col of the table ITAB_SOURCE.
        describe table itab_info lines v_max_col.
      * Get the number of row of the table ITAB_SOURCE.
        describe table itab_source lines v_max_row.
      
      
      
      * Work line by line of the table ITAB_SOURCE.
        do v_max_row times.
      
      *   New line.
          v_count_row = v_count_row + 1.
          clear v_count_col.
          move : '1-'        to struct_data-col_pos ,
                 v_count_row to struct_data-row_pos ,
                 v_count_row to struct_data-value+0(33).
          append struct_data to itab_data.
      
      *   Go col by col.
          do v_max_col times.
            v_count_col = v_count_col + 1.
            read table itab_info index v_count_col into struct_info.
            concatenate 'ITAB_SOURCE-'
                        struct_info-fieldname
                        into v_field.
            read table itab_source index v_count_row.
            assign (v_field) to <field>.
            move : <field> to struct_data-value ,
                   v_count_col to struct_data-col_pos ,
                   v_count_row to struct_data-row_pos ,
                   v_count_row to struct_data-row_id .
            append struct_data to itab_data.
          enddo.
      
        enddo.
      
      
      
      endform.                     " P_TRANS_TABLE
      
      
      
      
      
      
      *----------------------------------------------------------------------*
      *   Form P_CREATE_MAIL.                                                *
      *----------------------------------------------------------------------*
      *   Create an HTML mail.                                               *
      *----------------------------------------------------------------------*
      form p_create_mail.
      
      
        data : object_hd_change like sood1 occurs 0 with header line,
               objpara          like selc  occurs 0 with header line,
               receivers        like soos1 occurs 0 with header line,
               struct_user_adress like usaddress.
      
      
      
        concatenate c_title
                    'sur l''instance'
                    sy-sysid
                    into c_title
                    separated by space.
      
        move : 'HTM' to object_hd_change-file_ext ,
               c_title to object_hd_change-objdes.
        append object_hd_change.
      
      
      * Find email addr for the username.
        loop at s_bname.
      
          call function 'SUSR_USER_READ'
            exporting
              user_name                  = s_bname-low
            importing
              user_address               = struct_user_adress
            exceptions
              user_name_not_exists       = 1
              internal_error             = 2
              others                     = 3.
          select single smtp_addr
                 into receivers-recextnam
                 from adr6
                 where addrnumber eq struct_user_adress-addrnumber
                 and   persnumber eq struct_user_adress-persnumber.
          if sy-subrc eq space.
            move 'U' to receivers-recesc.
            append receivers.
          endif.
      
        endloop.
      
      
      * Send mail.
        call function 'SO_OBJECT_SEND'
             exporting
                 object_hd_change           = object_hd_change
                 object_type                = 'RAW'
                 owner                      = sy-uname
             tables
                 objcont                    = itab_result
                 objpara                    = objpara
                 receivers                  = receivers
      *           packing_list               = l_packing_list
      *           att_cont                   = fic_attach
             exceptions
                 others                     = 01.
      
      
      
      
      endform.                     " P_CREATE_MAIL.
      
      
      
      
      
      
      
      *----------------------------------------------------------------------*
      *   Form P_CLEAN_HTML.                                                 *
      *----------------------------------------------------------------------*
      *   Clean the HTML code.                                               *
      *----------------------------------------------------------------------*
      form p_clean_html tables itab_html type table
                        using  v_title
                               v_pos.
      
      
        data : v_first   type syindex ,
               v_last    type syindex ,
               v_buff    type w3_html ,
               v_num     type syindex ,
               itab_trav type table of w3html with header line .
      
      
      * Transfer to ITAB_TRAV.
        loop at itab_html.
          move itab_html to itab_trav-line.
          append itab_trav.
        endloop.
        refresh itab_html.
      
      
      * If first array.
        if v_pos eq 'F'.
      
      *   Delete boring stuff.
          loop at itab_trav.
            if itab_trav+0(7) eq 'BUTTON{'.
              move sy-tabix to v_first.
            endif.
            if itab_trav+0(18) eq '</FORM><!%_/A1F1!>'.
              move sy-tabix to v_last.
            endif.
          endloop.
          delete itab_trav from v_first to v_last.
      
      *   Add header style.
          concatenate '.HEADER1 {background:#6780B8; font-family:Arial ,'
                      'Helvetica,sans-serif; color:#FFFFFF;}'
                      into itab_trav-line.
          insert itab_trav-line into itab_trav index v_first.
          v_first = v_first + 1.
          itab_trav-line = '</STYLE>'.
          insert itab_trav-line into itab_trav index v_first.
          v_first = v_first + 1.
          concatenate '<H2>'
                      v_title
                      '</H2>'
                      into itab_trav-line.
          insert itab_trav-line into itab_trav index v_first.
      
      *   Add a title.
          concatenate '<TITLE>'
                      c_title
                      '</TITLE>'
                      into v_buff
                      separated by space.
          insert v_buff into itab_trav index 2.
      
      
      * If not the first array  erase all the header.
        else.
      
      *   Keep only the grid.
          loop at itab_trav.
            if itab_trav+0(14) eq '<table bgcolor'.
              move sy-tabix to v_first.
            endif.
            if itab_trav+0(18) eq '</td></tr></table>'.
              move sy-tabix to v_last.
            endif.
          endloop.
          v_first = v_first - 1.
          v_last  = v_last  + 1.
          describe table itab_trav lines v_num..
          delete itab_trav from v_last to v_num.
          delete itab_trav from 1      to v_first.
      *   Add title.
          move '</ br>' to v_buff.
          insert v_buff into itab_trav index 1.
          concatenate '<H2>'
                      v_title
                      '</H2>'
                      into itab_trav-line.
          insert itab_trav-line into itab_trav index 2.
      
      
        endif.
      
        if v_pos eq 'L'.
          move '</HTML>' to v_buff.
          insert v_buff into itab_trav index v_num.
        endif.
      
      
      * Transfer to ITAB_HTML.
        loop at itab_trav.
          move itab_trav-line to itab_html.
          append itab_html.
        endloop.
      
      
      
      endform.                     " P_CLEAN_HTML.

      Fred