Hi nagaraj,
i tried like this, it is working for me
data:
t_objbin type standard table of solisti1, " Attachment data
t_objtxt type standard table of solisti1, " Message body
t_objpack type standard table of sopcklsti1, " Packing list
t_reclist type standard table of somlreci1, " Receipient list
t_objhead type standard table of solisti1. " Header
data: wa_docdata type sodocchgi1, " Document data
wa_objtxt type solisti1, " Message body
wa_objbin type solisti1, " Attachment data
wa_objpack type sopcklsti1, " Packing list
wa_reclist type somlreci1. " Receipient list
data: w_tab_lines type i. " Table lines
types : begin of ty_sflight,
carrid type sflight-carrid,
connid type sflight-connid,
fldate type sflight-fldate,
price type sflight-price,
currency type sflight-currency,
planetype type sflight-planetype,
end of ty_sflight.
types : begin of ty_final,
carrid(3) type c,
connid(4) type c,
fldate(8) type c,
price(17) type c,
currency(5) type c,
planetype(10) type c,
end of ty_final.
data : it_sflight type table of ty_sflight,
wa_sflight type ty_sflight.
data : it_final type table of ty_final,
wa_final type ty_final.
* Start-of-selection
start-of-selection.
select carrid
connid
fldate
price
currency
planetype
from sflight into table it_sflight up to 10 rows.
loop at it_sflight into wa_sflight.
wa_final-carrid = wa_sflight-carrid.
wa_final-connid = wa_sflight-connid.
wa_final-fldate = wa_sflight-fldate.
wa_final-price = wa_sflight-price.
wa_final-currency = wa_sflight-currency.
wa_final-planetype = wa_sflight-planetype.
append wa_final to it_final.
clear wa_final.
endloop.
* Creating message
perform create_message.
* Sending Message
perform send_message.
*&---------------------------------------------------------------------*
*& Form create_message
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
form create_message .
**1 Title, Description & Body
perform create_title_desc_body.
**2 Receivers
perform fill_receivers.
endform. " create_message
*&---------------------------------------------------------------------*
*& Form CREATE_TITLE_DESC_BODY
*&---------------------------------------------------------------------*
* Title, Description and body
*----------------------------------------------------------------------*
form create_title_desc_body.
*...Title
wa_docdata-obj_name = 'Email notification'.
*...Description
wa_docdata-obj_descr = 'Email body in HTML'.
*...Message Body in HMTL
wa_objtxt-line = '<html> <body style="background-color:#FFE4C4;">'.
append wa_objtxt to t_objtxt.
wa_objtxt-line = '<p> List of Test materials </p>'.
append wa_objtxt to t_objtxt.
* table display
wa_objtxt-line = '<table style="MARGIN: 10px" bordercolor="#90EE90" '.
append wa_objtxt to t_objtxt.
wa_objtxt-line = ' cellspacing="0" cellpadding="3" width="400"'.
append wa_objtxt to t_objtxt.
wa_objtxt-line = ' border="1"><tbody><tr>'.
append wa_objtxt to t_objtxt.
* table header
wa_objtxt-line = '<th bgcolor="#90EE90">Airline & Code</th>'.
append wa_objtxt to t_objtxt.
wa_objtxt-line = '<th bgcolor="#90EE90">Flight Connection Number</th>'.
append wa_objtxt to t_objtxt.
wa_objtxt-line = '<th bgcolor="#90EE90">Flight date</th>'.
append wa_objtxt to t_objtxt.
wa_objtxt-line = '<th bgcolor="#90EE90">Airfare</th>'.
append wa_objtxt to t_objtxt.
wa_objtxt-line = '<th bgcolor="#90EE90">Local currency of airline</th>'.
append wa_objtxt to t_objtxt.
wa_objtxt-line = '<th bgcolor="#90EE90">Aircraft Type</th></tr>'.
append wa_objtxt to t_objtxt.
* table Contents
loop at it_final into wa_final.
wa_objtxt-line = '<tr style="background-color:#eeeeee;">'.
append wa_objtxt to t_objtxt.
concatenate '<td>' wa_final-carrid '</td>' into wa_objtxt-line.
append wa_objtxt to t_objtxt.
concatenate '<td>' wa_final-connid '</td>' into wa_objtxt-line.
append wa_objtxt to t_objtxt.
concatenate '<td>' wa_final-fldate '</td>' into wa_objtxt-line.
append wa_objtxt to t_objtxt.
concatenate '<td>' wa_final-price '</td>' into wa_objtxt-line.
append wa_objtxt to t_objtxt.
concatenate '<td>' wa_final-currency '</td>' into wa_objtxt-line.
append wa_objtxt to t_objtxt.
concatenate '<td>' wa_final-planetype '</td></tr>' into wa_objtxt-line.
append wa_objtxt to t_objtxt.
clear wa_final.
endloop.
* table close
wa_objtxt-line = '</tbody> </table>'.
append wa_objtxt to t_objtxt.
* Signature with background color
wa_objtxt-line = '<br><br>'.
append wa_objtxt to t_objtxt.
wa_objtxt-line = '<p> Regards,</p>'.
append wa_objtxt to t_objtxt.
wa_objtxt-line = '<p style="background-color:#1E90FF;"><b> Your Name</b></p>'.
append wa_objtxt to t_objtxt.
* HTML close
wa_objtxt-line = '</body> </html> '.
append wa_objtxt to t_objtxt.
* Document data
describe table t_objtxt lines w_tab_lines.
read table t_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 t_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 t_reclist.
clear wa_reclist.
endform. " fill_receivers
*&---------------------------------------------------------------------*
*& Form send_message
*&---------------------------------------------------------------------*
* Sending Mail
*----------------------------------------------------------------------*
form send_message .
* Send Message to external Internet ID
call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
exporting
document_data = wa_docdata
put_in_outbox = 'X'
commit_work = 'X' "used from rel.6.10
tables
packing_list = t_objpack
object_header = t_objhead
contents_txt = t_objtxt
receivers = t_reclist
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 ne 0.
write: 'Sending Failed'.
else.
write: 'Sending Successful'.
endif.
endform. " send_message