Beruflich Dokumente
Kultur Dokumente
The requirement is to send internal table data in mail body instead of sending as attachment in mail. Mail body internal table data should display with different colors based on conditions.
Advantage
1. 2. 3.
Not required to open mail attachment to see information on it, it displays mail body itself. Color indication based on conditions, it helps for better analysis.
2. Create HTML mail content. The HTML content is prepared and filled in table it_final which would be later used to create HTML form.
<html> tag tells the browser that this is an HTML document. <body> tag is used to defines the document's body. <font> tag is used to use to give the style to the content. <style> tag is used to define style information for an HTML document. <th> tag defines a header cell in an HTML table. <tr> tag defines a row in an HTML table. Code:
*...Title wa_docdata-obj_name = 'Email notification'. *...Description wa_docdata-obj_descr = 'Internal Table in Email Body'. *...Message Body in HMTL wa_objtxt-line = '<html> <body style="background-color:#FFE4C4;">'. APPEND wa_objtxt TO it_objtxt. wa_objtxt-line = '<p> List of Test materials </p>'. APPEND wa_objtxt TO it_objtxt. * table display wa_objtxt-line = '<table style="MARGIN: 10px" bordercolor="NavajoWhite" '. APPEND wa_objtxt TO it_objtxt. wa_objtxt-line = ' cellspacing="0" cellpadding="3" width="800"'. APPEND wa_objtxt TO it_objtxt. wa_objtxt-line = ' border="1"><tbody><tr>'. APPEND wa_objtxt TO it_objtxt. * table header wa_objtxt-line = '<th><font color="RoyalBlue">Airline Code</font></th>'. APPEND wa_objtxt TO it_objtxt. wa_objtxt-line = '<th><font color="RoyalBlue">Flight</font></th>'. APPEND wa_objtxt TO it_objtxt. wa_objtxt-line = '<th><font color="RoyalBlue">Flight date</font></th>'. APPEND wa_objtxt TO it_objtxt. wa_objtxt-line = '<th><font color="RoyalBlue">Aircraft Type</font></th>'. APPEND wa_objtxt TO it_objtxt. wa_objtxt-line = '<th><font color="RoyalBlue">Maximum capacity</font></th>'. APPEND wa_objtxt TO it_objtxt. wa_objtxt-line = '<th><font color="RoyalBlue">Occupied seats</font></th>'. APPEND wa_objtxt TO it_objtxt. wa_objtxt-line = '<th><font color="RoyalBlue">Occupied %</font></th></tr>'. APPEND wa_objtxt TO it_objtxt. * table Contents LOOP AT it_final INTO wa_final.
wa_objtxt-line = '<tr>'. APPEND wa_objtxt TO it_objtxt. var = wa_final-percentage. IF var GE '50'. CONCATENATE '<td><center>' wa_final-carrid '</center></td>' INTO wa_objtxt-line. APPEND wa_objtxt TO it_objtxt. CONCATENATE '<td><center>' wa_final-connid '</center></td>' INTO wa_objtxt-line. APPEND wa_objtxt TO it_objtxt. CONCATENATE '<td><center>' wa_final-fldate '</center></td>' INTO wa_objtxt-line. APPEND wa_objtxt TO it_objtxt. CONCATENATE '<td><center>' wa_final-planetype '</center></td>' INTO wa_objtxt-line. APPEND wa_objtxt TO it_objtxt. CONCATENATE '<td><center>' wa_final-seatsmax '</center></td>' INTO wa_objtxt-line. APPEND wa_objtxt TO it_objtxt. CONCATENATE '<td><center>' wa_final-seatsocc '</center></td>' INTO wa_objtxt-line. APPEND wa_objtxt TO it_objtxt. CONCATENATE '<td><center>' wa_final-percentage '%' '</center></td></tr>' INTO wa_objtxt-line. APPEND wa_objtxt TO it_objtxt. ELSE. CONCATENATE '<td><center><font color="Red">' wa_final-carrid '</font></center></td>' INTO wa_objtxt-line. APPEND wa_objtxt TO it_objtxt. CONCATENATE '<td><center><font color="Red">' wa_final-connid '</font></center></td>' INTO wa_objtxtline. APPEND wa_objtxt TO it_objtxt. CONCATENATE '<td><center><font color="Red">' wa_final-fldate '</font></center></td>' INTO wa_objtxt-line. APPEND wa_objtxt TO it_objtxt. CONCATENATE '<td><center><font color="Red">' wa_final-planetype '</font></center></td>' INTO wa_objtxtline. APPEND wa_objtxt TO it_objtxt. CONCATENATE '<td><center><font color="Red">' wa_final-seatsmax '</font></center></td>' INTO wa_objtxtline. APPEND wa_objtxt TO it_objtxt. CONCATENATE '<td><center><font color="Red">' wa_final-seatsocc '</font></center></td>' INTO wa_objtxtline. APPEND wa_objtxt TO it_objtxt. CONCATENATE '<td><center><font color="Red">' wa_finalpercentage '%' '</font></center></td></tr>' INTO wa_objtxt-line. APPEND wa_objtxt TO it_objtxt. ENDIF. CLEAR : wa_final, var. ENDLOOP. * table close wa_objtxt-line = '</tbody> </table>'. APPEND wa_objtxt TO it_objtxt. * Signature color
wa_objtxt-line = '<br><br>'. APPEND wa_objtxt TO it_objtxt. wa_objtxt-line = '<p> Regards,</p>'. APPEND wa_objtxt TO it_objtxt. wa_objtxt-line = '<p><b> Your Name</b></p>'. APPEND wa_objtxt TO it_objtxt. * HTML close wa_objtxt-line = '</body> </html> '. APPEND wa_objtxt TO it_objtxt. * Document data DESCRIBE TABLE it_objtxt LINES w_tab_lines. READ TABLE it_objtxt INTO wa_objtxt INDEX w_tab_lines. wa_docdata-doc_size = ( w_tab_lines - 1 ) * 255 + STRLEN( wa_objtxt ). * Packing data CLEAR wa_objpack-transf_bin. wa_objpack-head_start = 1. wa_objpack-head_num = 0. wa_objpack-body_start = 1. wa_objpack-body_num = w_tab_lines. * we will pass the HTML, since we have created the message * body in the HTML wa_objpack-doc_type = 'HTML'. APPEND wa_objpack TO it_objpack. ENDFORM. " CREATE_TITLE_DESC_BODY
*&---------------------------------------------------------------------* *& Form fill_receivers *&---------------------------------------------------------------------* * Filling up the Receivers *----------------------------------------------------------------------* FORM fill_receivers . wa_reclist-receiver = 'ramesh@gmail.com'. wa_reclist-rec_type = 'U'. APPEND wa_reclist TO it_reclist. CLEAR wa_reclist.
ENDFORM.
" fill_receivers
Output in SOST.