Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8789

Re: Hyperlink to Image in email Body

$
0
0

Yes I have added the image now I need to give the hyperlink to the image that I have added if user click on that Image it should navigate to that page. Below is my code

 

IF gv_mr_api IS INITIAL.

 

   gv_mr_api = cl_mime_repository_api=>if_mr_api~get_api( ).

 

ENDIF.

 

CALL METHOD gv_mr_api->get

   EXPORTING

     i_url = '/SAP/PUBLIC/ALM 7111 Market text.jpg'  "Image path

   IMPORTING

     e_is_folder = is_folder

     e_content = gv_content

     e_loio = l_loio

   EXCEPTIONS

  parameter_missing  = 1

     error_occured = 2

     not_found = 3

  permission_failure = 4

     OTHERS = 5.

 

   "Convert Image to Xstring table form

 

l_obj_len = XSTRLEN( gv_content ).

lv_graphic_length = XSTRLEN( gv_content ).

 

"get whole image

CLEAR gr_xstr.

gr_xstr = gv_content(l_obj_len).

 

l_offset = 0.

l_length = 255.

 

CLEAR lt_solix[].

WHILE l_offset <  lv_graphic_length.

   l_diff = lv_graphic_length - l_offset.

   IF l_diff > l_length.

     ls_solix-line = gr_xstr+l_offset(l_length).

   ELSE.

     ls_solix-line = gr_xstr+l_offset(l_diff).

   ENDIF.

   APPEND ls_solix TO lt_solix.

   ADD l_length TO l_offset.

ENDWHILE.

 

*Attach image to HTML body

l_filename = 'img_market.jpg'.

l_content_id = 'img_market.jpg'.

 

CREATE OBJECT lo_mime_helper.

CALL METHOD lo_mime_helper->add_binary_part

   EXPORTING

     content = lt_solix                   "Xstring in table form

     filename = l_filename                 "file name to be given to image

     extension = 'JPG'                      "type of file

     description = 'Graphic in JPG format'    "description

     content_type = 'image/jpg'                "content type / Mime type. If mime type not present in system then need to add through tcode : SMW0

     length = l_obj_len                  "length of image

     content_id = l_content_id.              "content id would be used in html part

 

"Create HTML mail body Content

REFRESH lt_soli[].

 

"For displaying Image

CLEAR ls_soli.

ls_soli = '&lt;br>&lt;img alt="[image]" src="cid:img_market.jpg" />&lt;br>'.

APPEND ls_soli TO lt_soli.

 

"Create main HTML body

*CREATE OBJECT lo_mime_helper.

CALL METHOD lo_mime_helper->set_main_html

   EXPORTING

     content = lt_soli.


Viewing all articles
Browse latest Browse all 8789

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>