SENDING SMART FORMS IN THE FORMOF HTML FORMAT. Yeah there are already documents available on this topic. Only reason why i am posting this document is the difference in the code. There are some classes availabe, which will be very useful in the process of sending smart forms in the HTML format. this report program will give you an idea on how to convert smart form into html format and send it as an email along with the images(if smart form consists any ). There is no need of manipulating much on images content. All we need to do is just covert the image into binary content. There is a class in SAP CRM cl_crm_email_data , which has one method send_email, which will help us to make this process quite easy. We can easily embed the images in to the email content. Observe this class closely, may be you can get more ideas. Eventhough , i used appropriate comments in the program. It would be better if i tell you some importants points here only. There is some piece of code in the report program regarding image maniplation. the basic logic is , if there is one image in the smart form, then there will be one img tag in the converted html output. This img tag will have one attribute called 'src'. The one possible value for this attribute will be like this"cid:xxxxxx" .here 'xxxxxx' is image name. This image name and the value for content id, which we will send to one internal table(see the report program) , should be same. This will help the email client to find out the embedded image in the email. i have written this program assuming that smart form will have only one image.you can modify it according to your requirements. i hope users already have some basic knowledge on XSF format. please refere to below link if you want to know more about XSF fomrat and parameters we need to send to convert smart form into HTML format. http://help.sap.com/SAPHELP_NW04s/helpdata/EN/a5/28d3b6d26211d4b646006094192fe3/content.htm For the people, who want to investigate furhther on this topic. There is one report program available in SE38 transaction. SF_XSF_DEMO_MAIL. kindly check it. I hope it helps you. Any suggestions are welcome. Generated by Jive on 2014-12-19+01:00 1 "control parameters. lt_graphics TYPE tsf_xsf_gr. ls_control_parameters ls_part TYPE ssfctrlop. ref_tag_index TYPE i. TYPES: lt_mail_html_parset TYPE STANDARD TABLE OF ty_cmail_html_parser. "SAP Smart Forms: Table With Archive Indexes "Image information lt_mail_html_parset. lt_result TYPE lt_imageid "image source information. *****************local structure*********************************** DATA: ls_output_options TYPE ssfcompop. attributes TYPE tihttpnvp. "Joboutput information. "parametes to get html format. ***************************LOCAL INTERNAL TABLES***************************************************** DATA : lt_html_raw TYPE tsfixml. "to email addresses lt_cc TYPE crmt_email_recipients. lt_archive TYPE tsfdara.SENDING SMART FORMS IN THE FORM OF HTML FORMAT."partsed html information Generated by Jive on 2014-12-19+01:00 2 . TYPE TABLE OF string. TYPES: BEGIN OF ty_cmail_html_parser. ls_job_output_info TYPE ssfcrescl. "CC email addresses. "parsed html information. END OF ty_cmail_html_parser. lt_mail_body "image ids TYPE crmt_email_mime_struc. TYPE REF TO "output information in XML format. ls_xsfparam_line TYPE ssfxsfp. match_result_tab. tag TYPE string. "output options. is_end_tag TYPE xfeld. part TYPE string. REPORT zsmartform_send_mail. ls_xmloutput TYPE ssfxmlout. ty_cmail_html_parser. "find stament result TYPE TABLE OF string. lt_to TYPE crmt_email_recipients. lt_part TYPE lt_imgsrc "XML output information. TYPE "Name of function module of smart form. ls_graphic TYPE ssf_xsf_gr. "body content type. TYPE "html data. ls_recep LIKE LINE OF "message id. i. TYPE LINE OF crmt_email_image. cl_crm_email_data. Generated by Jive on 2014-12-19+01:00 3 . lc_contentid TYPE string VALUE 'CONTENT-ID'. "image information. ls_attribute TYPE REF TO ls_imgsrc LIKE LINE OF lt_imgsrc. "image tag "body html . lt_to. string. LIKE LINE OF lt_mail_body. ls_imageinfo "image information "business service document file content ihttpnvp. "TO email addresses ****************local variables**************************************** DATA: lv_function_name lv_xstring TYPE TYPE lv_html_xstring rs38l_fnam. "mail data object "activity guid string. sysuuid_x. string. TYPE lo_create_mail "Xstring data. xstring. ***************************constants************************************* DATA : lc_flag lc_outmode TYPE c VALUE 'X'. lc_text_html lc_body_html TYPE string VALUE 'body. "Application mode lc_graphics TYPE string lc_extract TYPE string VALUE 'GRAPHICS'.SENDING SMART FORMS IN THE FORM OF HTML FORMAT. xstring. TYPE string VALUE 'text/html'. "flag constant TYPE c VALUE 'A'. "conversion class. ls_gr_raw TYPE bapiconten. lc_enable VALUE 'ENABLE'. TYPE REF TO "image source value. "Length of the string. "html tag attribute information. "src property of image tag.htm'. TYPE REF TO lv_imagename "Xstring data. lc_src TYPE string VALUE 'src'. VALUE 'EXTRACT'. "image source information. TYPE lo_conv lv_html_temp lv_len TYPE TYPE lv_img_src lv_activity cl_abap_conv_in_ce. ls_result LIKE LINE OF lt_result. TYPE string "parameter "Parameter "content id "enable lc_img TYPE string VALUE 'img'. ls_mail_body "find result. "(XML output for Smart Form) FORMAT. " Get XSF params from program ls_output_options-xsfoutmode = lc_outmode. ls_xsfparam_line-name = lc_contentid. CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME' EXPORTING formname = lv_form IMPORTING fm_name = lv_function_name EXCEPTIONS no_form =1 no_function_module = 2 OTHERS = 3. ls_xsfparam_line-value = lc_enable. PARAMETERS : lv_form TYPE tdsfname. " A:Application ls_output_options-xsfformat = lc_flag. lv_mail TYPE string. IF sy-subrc IS INITIAL. ls_xsfparam_line-value = lc_extract. CLEAR lv_function_name. "filling the necesary parameters to get the smartform data "in XSF (XML OUPUT FOR SMART FORMS) format. " XSF Output active ls_output_options-xsfcmode = lc_flag. "#EC NOTEXT "#EC NOTEXT APPEND ls_xsfparam_line TO ls_output_options-xsfpars. ls_output_options-xsf = lc_flag.SENDING SMART FORMS IN THE FORM OF HTML FORMAT. "email address "getting the smartform function module. "smart form name. Generated by Jive on 2014-12-19+01:00 4 . " Formatting ON "#EC NOTEXT "#EC NOTEXT APPEND ls_xsfparam_line TO ls_output_options-xsfpars. ls_xsfparam_line-name = lc_graphics. CLEAR ls_output_options. lt_graphics[] = ls_job_output_info-xmloutput-xsfgr[]. "_____________getting the html format_______________________" CLEAR : lv_xstring. "calling the smartform function module. "converting from RAW fromat to XSTRING format. LOOP AT lt_html_raw INTO lv_xstring. "image information. CONCATENATE lv_html_xstring lv_xstring INTO lv_html_xstring IN BYTE MODE. Generated by Jive on 2014-12-19+01:00 5 . lt_html_raw = ls_xmloutput-trfresult-content[].SENDING SMART FORMS IN THE FORM OF HTML FORMAT. lv_html_xstring. check sy-subrc is initial. ls_xmloutput = ls_job_output_info-xmloutput. CALL FUNCTION lv_function_name EXPORTING control_parameters = ls_control_parameters output_options = ls_output_options user_settings ='' IMPORTING job_output_info = ls_job_output_info EXCEPTIONS formatting_error = 1 internal_error =2 send_error =3 user_canceled OTHERS =4 = 5. CLEAR ls_control_parameters. "finding the source property value of the image (IMG SRC) in the "html string. lv_img_src = ls_attribute->value+1(lv_len).2. Generated by Jive on 2014-12-19+01:00 6 . ELSE. CALL METHOD cl_crm_html_parser=>parse_html_string EXPORTING iv_html = lv_html_temp iv_all_tags_lower_case = lc_flag IMPORTING et_parts = lt_part. ENDLOOP. lo_conv = cl_abap_conv_in_ce=>create( input = lv_html_xstring ). "now we have our smart form data in the hmtl format . "we need to extract image information from the html string so that later "we can embed the image. CLEAR ls_attribute. CLEAR lt_part[].SENDING SMART FORMS IN THE FORM OF HTML FORMAT. so later we can use it when embedding the "image. lo_conv->read( IMPORTING data = lv_html_temp ). "parse the html string tag by tag. READ TABLE ls_part->attributes REFERENCE INTO ls_attribute WITH TABLE KEY name = lc_src. "converting from XSTRING format to STRING format. CLEAR ls_part. IF ls_attribute->value(1) = '"'. lv_len = STRLEN( ls_attribute->value ) . IF sy-subrc IS INITIAL. LOOP AT lt_part REFERENCE INTO ls_part WHERE tag = lc_img. "here content id which is there in the html string and content id that\ "we are sending in this internal table should be same. CLEAR lv_img_src. READ TABLE lt_imgsrc INTO lv_img_src INDEX lv_len. "converting each image content into binary format.SENDING SMART FORMS IN THE FORM OF HTML FORMAT. ENDLOOP. LOOP AT lt_graphics INTO ls_graphic. "embedding the images inside the body. LOOP AT ls_graphic-content INTO ls_gr_raw. Generated by Jive on 2014-12-19+01:00 7 . ls_mail_body-is_attachment = lc_flag. REPLACE ALL OCCURRENCES OF 'cid:' IN lv_img_src WITH space. CLEAR : ls_gr_raw. CLEAR lv_imagename. ENDLOOP. lv_img_src = ls_attribute->value. ENDIF. ENDIF. lv_len = 1. CONCATENATE ls_graphic-graphics '. lv_html_xstring.bmp' INTO lv_imagename. CLEAR ls_mail_body. APPEND lv_img_src TO lt_imgsrc. CLEAR lv_len. ls_mail_body-content_bin = lv_html_xstring. CLEAR ls_gr_raw. CONCATENATE lv_html_xstring ls_gr_raw-line INTO lv_html_xstring IN BYTE MODE. CLEAR ls_mail_body. APPEND ls_recep TO lt_to. "moving the subject. REPLACE FIRST OCCURRENCE OF lv_img_src IN lv_html_temp WITH lv_imagename. CREATE OBJECT lo_create_mail. ls_mail_body-mime_type = lc_text_html. ls_mail_body-content_ascii = lv_html_temp. ls_mail_body-file_name = lc_body_html. ls_mail_body-content_id = lv_imagename.SENDING SMART FORMS IN THE FORM OF HTML FORMAT. "filling body of the mail. "moving the body MOVE lt_mail_body TO lo_create_mail->body. ls_mail_body-mime_type = ls_graphic-httptype. ENDLOOP. ls_mail_body-file_name = lv_imagename. Generated by Jive on 2014-12-19+01:00 8 . "filling to email address CLEAR ls_recep. ls_recep-address = lv_mail . APPEND ls_mail_body TO lt_mail_body. ENDIF. MOVE 'smart form as html mail' TO lo_create_mail->subject. clear lv_html_xstring. lv_len = lv_len + 1. "create mail object. IF sy-subrc IS INITIAL. APPEND ls_mail_body TO lt_mail_body. SENDING SMART FORMS IN THE FORM OF HTML FORMAT. "calling method to send the email CALL METHOD cl_crm_email_utility_base=>send_email EXPORTING iv_mail_data = lo_create_mail RECEIVING ev_send_request_id = lv_activity. Generated by Jive on 2014-12-19+01:00 9 . "moving to addresses MOVE lt_to TO lo_create_mail->to. "send the email. ENDIF. COMMIT WORK.