Skip to Content
Author's profile photo Purvang Gandhi

Image in Mail body in ABAP

Objective

  • The requirement was to send the Birthday Mails to Employee along with image in mail body. Generally, the images are send as attachment in mail but to send the image in the mail body different approach is to be used.The main objective of this document is to send the image in email body. I searched on portals and google to resolve it but couldn’t find proper solution , so decided to post the document on finding solution.

Challenges

  • To use image in mail there are many options through direct HTML code and CL_BCS class but image appears as attachment and in body “X” icon appears, browsers and mail servers behaves  differently for HTML code.
  • There are four possible solutions according to me


    1. To upload image on any server open to Internet and use that image path in html code. It will work in all case except those were external links are blocked by mail server or the image is removed from the given path.
    2. To convert image to base64 code and append the whole string in image. It will work but string is very long and if not converted properly then image does not appears in mail body as required.
    3. To upload image in smart-form and convert that smart-form to HTML then create html document and embed image to the mail using BCS class. It will work but the limitation is that in smartforms only BMP image types are supported which reduces the quality of image. The styles applied in smartforms are available in html but browsers suppresses the CSS and styles. So no styles will be seen in mail.To use the style they are to be applied inline through html code using tags like <font>,<i>&<b>,etc.
    4. To upload image in MIME Repository. Get the Image from MIME Repository in report and convert it to xstring table form.Using class cl_gbt_multirelated_service combine HTML content and image. Create HTML content and attach image to mail body using BCS class  and assign sender and receivers.


  • The 4th Approach was more feasible and appropriate as it has high availabilty of image in mail body which fulfills the primary requirement.


Advantage

  • It is quite simple and easy approach to embed image in mail body.
  • It can be reused for sending images in mail body.
  • We can give desired styling using inline HTML tags which avoids the usage of css as they are not rendered by many web browsers and mail severs.
  • High availabilty of image in mail and no other objects like smartforms are required,use multiple images in mail body.   

Disadvantage

  • The web browsers and mail severs behave differently while rendering HTML page. We use CID (Context Id ) to display image in HTML body.It is possible that some browsers/mail servers don’t allow to render image in mail body using CID but atleast we would have the image as attachment.


  • Tested for OUTLOOK, ZIMBRA works well on it.


Steps for sending the image in mail

  1. Upload Image in MIME repository.
  2. Get image from mime reporsitory in form of xstring  
  3. Convert the image from xstring to table form ( i.e. solix_tab )
  4. Attach Image in xstring form to HTML form.
  5. Create mail content.
  6. Create HTML form with HTML content.
  7. Create Mail using BCS class.

1. Upload Image in MIME repository.

    

  •      There are many options to upload image in Mime Repository. I have implemented using SE80 TCODE.
  •       It can also be implemented through report using
    • Class : CL_MIME_REPOSITORY_API
    • Method: IF_MR_API~PUT

      1.     Provide TCODE SE80.


      2.     Click on Mime Repository.

     /wp-content/uploads/2013/06/mime2_229787.jpg

      3.     Select Directory where the image is to be uploaded , right click on directory and select “Import MIME Objects” ( Here the directory                is “PUBLIC” ).

       /wp-content/uploads/2013/06/mime3_229789.jpg


     4.     Browse the System and Select the required image to be uploaded from the system then following screen would appear,provide                           description and click on save button.

     /wp-content/uploads/2013/06/mime4_229793.jpg

     5.     On Saving the image the system would prompt for object package , Save it in associated package or local object as per the                                 requirement.


     6.     Now the image would appear in the folder and by clicking on image we can get the preview as shown below.

     /wp-content/uploads/2013/06/mime6_229794.jpg

2. Get image from mime repository in form of xstring


  • Create the report as per the logic required(requirement was to send birthday mails) and we can add the image part and html body      to it
  • Get the image stored in mime repository in the report using 
    • Class: cl_mime_repository_api 
    • Method: if_mr_api~get_api
  • Here in parameter i_url the image path is to be given to obtain the image in xstring form.

  • CODE:

     /wp-content/uploads/2013/06/step2_229799.jpg

3. Convert the image from xstring to table form ( i.e. solix_tab )

  • In variable gv_content the image is in form of xstring.
  • To attach that image in mail we have to convert it to table form of Xstring which contains      row of type xstring and length 255 char


  • The lt_solix table contains the image in xstring table form which would be attached to mail body.
  • CODE

     /wp-content/uploads/2013/06/step3_229800.jpg

4. Attach Image in xstring


  •   In variable l_filename the name is given to the image that is created and in variable      l_content_id the content id (CID) is assigned which   would be later used in the html content.
  • The variable lt_solix contains the image in xstring table form.
  • The variable l_obj_len contains the length of image which was calculated earlier
  • The content type is the mime type of the content in lt_solix
  • For .jpg image it is image/jpg. Similarly for bmp – image/bmp, gif – image/gif , etc
  •   Attach image using 
    • Class : cl_gbt_multirelated_service
    • Method: add_binary_part
    • Object : lo_mime_helper
  • CODE:

     step 4.jpg    


  • If mimetype/content type is not available in system then we need to add it through following steps

           TCODE : SMW0.

    

                1. Execute TCODE : SMW0

                      step 4 1.jpg

               2. Press F8           

                              step 4 2.jpg

 

                3. Press F8

                      step 4 3.png

            4. In Menu , Goto Settings –> Maintain MIME Types.Click on Create button

                    step 4 4.jpg

    • If the desired mime type is not present then the required mime type can be created using above steps

 

5. Create HTML mail content.


  • The HTML content is prepared and filled in table lt_soli which would be later used to create      HTML form.
  • <font> tag is used to use to give the style to the content.
  • <img> tag is used for using image in html body.
  • In <img> the content id (CID) should be same as the content Id given in above step while      attaching image.
  • Code:

          step 5.jpg                                                         

         6.Create HTML form with HTML content.


  •      The created html content in table lt_soli is to be attached to create a HTML form using
      • Class : cl_gbt_multirelated_service
      • Method: set_main_html
      • Object : lo_mime_helper
  •     Code

               step 6.jpg

7. Create Mail using BCS class.

  • Now using the CL_BCS class we can embed html body and image assigning sender and      receivers.
  • Code:

          step 7.jpg

Output in SOST.

          /wp-content/uploads/2013/06/image1_231323.jpg

Output in Mail Client.

            /wp-content/uploads/2013/06/image2_231332.jpg

The Source Code is attached in a text file.

cheers!!!

Assigned Tags

      55 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Dirk Wittenberg
      Dirk Wittenberg

      Hi Purvang,

      thank's for this detailed blog. I will try it when my daily work allows it.

      Go on with this thorough work.

      Kind regards,

      Dirk

      Author's profile photo Christian Guenter
      Christian Guenter

      Hi Purvang,

      nice Blog.

      You can replace the code in step 3 with a call to the class-method XSTRING_TO_SOLIX from class CL_BCS_CONVERT.

      This makes your code cleaner, less error prone and saves you some work. Just don't reinvent the wheel.

      Regards Christian

      Author's profile photo Purvang Gandhi
      Purvang Gandhi
      Blog Post Author

      Hi Christian,

      Thanks for the suggestion !! ūüôā

      Thanks & Regards

      purvang

      Author's profile photo Jelena Perfiljeva
      Jelena Perfiljeva

      Thank you for sharing! I especially liked how you outlined all the steps first and then went into details. Well done.

      Maybe some kind of a web service to call Someecards would be a good alternative, er? ūüôā

      Author's profile photo Purvang Gandhi
      Purvang Gandhi
      Blog Post Author

      Hi Jelena,

      I think that for using web service for calling e-cards would work if the mail servers allow to the access to other/private web services.

      Thanks for the suggestion would try that way. ūüôā

      Author's profile photo Former Member
      Former Member

      Hi Purvang,

      Thanks for sharing this, just the couple of days back, i got the same requirement and i am working on it. Now you made my work easy.

      Cheers for you...

      Author's profile photo Former Member
      Former Member

      Hi,

      I have tried to send the logo to my gmail id and outlook still it is coming as attached file only not in the body of the mail can you please help me I have attached the screenshot here.

        Even in SOST image is not showing me as per your screen shoot.Please help me.

      Regards,

      Ravi Shankar L

      Author's profile photo Former Member
      Former Member

      In Outlook even attachments itself not able to find

      Author's profile photo Jayakumar K B
      Jayakumar K B

      Just check the HTML part  for the Image File.

      confirm the same name throughout the program. that will solve this issue. please check the underlined part of your code.

      CALL METHOD gv_mr_api->get

         EXPORTING

           i_url = '/SAP/PUBLIC/turtle.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.

      l_filename = 'turtle.jpg'.

      l_content_id = 'turtle.jpg'.

      ls_soli = '<br><img  src="turtle.jpg" width = "150px" height = "150px"/><br>'.

      Author's profile photo Former Member
      Former Member

      Hi Jayakumar,

      CALL METHOD gv_mr_api->get

         EXPORTING

           i_url = '/SAP/PUBLIC/ZSG_LOGOS/ZWeber_Logo.jpg'  "Image path

      *Attach image to HTML body

      l_filename = 'ZSG_LOGOS/ZWeber_Logo.jpg'.

      l_content_id = 'ZSG_LOGOS/ZWeber_Logo.jpg'.

      "For displaying Image

      CLEAR ls_soli.

      *ls_soli = '<lt;br><lt;img alt="[image]" src="cid:ZSG_LOGOS/ZWeber_Logo.jpg" /><lt;br>'.

      ls_soli = '<br><img  src="ZSG_LOGOS/ZWeber_Logo.jpg" width = "150px" height = "150px"/><br>'.

      APPEND ls_soli TO lt_soli.

      I am getting frame allocated for that image but image is not placing there

      Dear Ravi Shankar ,

      Regards, Testing Team Sigma

      Still mail is sending only in attachment please help me...... what mistake I am doing here...

      Regards,

      Ravi Shankar L



      Author's profile photo Purvang Gandhi
      Purvang Gandhi
      Blog Post Author

      Hi Ravi,

      Please check if file name & content id is added as below

      l_filename = 'ZSG_LOGOS/ZWeber_Logo.jpg'.
      l_content_id = 'ZSG_LOGOS/ZWeber_Logo.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     length       = l_obj_len                  "length of image
          content_id   = l_content_id.              "content id would be used in html part

      If it's fine then try inserting below line for image

      '<br><img alt="[image]" src="cid:ZSG_LOGOS/ZWeber_Logo.jpg" /><br>'

      I think the problem is in HTML code.

      If problem still persists you can mail me
      that part of code if it's fine for you so
      that I can check code.

      Regards
      Purvang

      Author's profile photo Former Member
      Former Member

      Please tell your mail ID ..... I will send my program...... Thanks in advance for your help

      Author's profile photo oguz ilhan
      oguz ilhan

      Hello can u please send me as well

      Author's profile photo Virendra Kedia
      Virendra Kedia

      Nice one Dear!

      Very useful. Can you please help me in the below scenario?

      I want to convert some texts, tables into an image file dynamically and then use that image to make a PDF file so that my PDF file will not be editable even someone has opened it with any editor tool.

      Can we do that? If yes, then how?

      Thanks and Regards,

      Virendra Kedia

      Author's profile photo Jayakumar K B
      Jayakumar K B

      use smartforms to create the formatted text and then convert it to PDF.

      Author's profile photo Purvang Gandhi
      Purvang Gandhi
      Blog Post Author

      Hi Virendra,

      If your primary requirement is to make PDF non editable then please go for digitally signed PDF or making it password protect or using SSF(provided by SAP) it would be more secured.

      Even there are tools available which would read text from images in PDF.

      I haven't came across any such class or method to convert text/tables to an image will search on it and let you know if I find any.

      You can use any third party tool (many are online) to convert text to image and save those images somewhere either in MIME repository or Application server.

      You can upload this image to smart-form and then convert smart-form to PDF or other way is to convert image to binary content and then convert the binary content to PDF(OTF).

      Hope this helps!!!! ūüôā

      Thanks & Regards

      purvang

      Author's profile photo Former Member
      Former Member

      I got one more spark from this link..... It is possible to upload video files "*.avi,etc" in MIME repository if we click it from there means video running succesfully same way If I press some button I need to play that video.....  If any one have idea about it please share it...  Thanks in advance.

      Regards,

      Ravi Shankar L

      Author's profile photo Purvang Gandhi
      Purvang Gandhi
      Blog Post Author

      Hi Ravi,

      I tried uploading AVI file in MIME Repository and it works.

      We just need to add a MIME Type(*.avi) as I mentioned in the document through transaction SMW0 the same way as we did for images.

      On clicking the AVI file it will open on your PC's default media player and start playing.

      check the below link to have your media player in SAP it would be fun :

      http://scn.sap.com/people/thomas.jung/blog/2005/05/11/using-classic-activex-controls-in-the-abap-control-framework

      Thanks & Regards

      purvang

      Author's profile photo Former Member
      Former Member

      I am trying to play this video file if I click one button in report it want to run it is possible? IN MIME it running successfully from program I need to call this If you have any idea please share me....

      Author's profile photo Rodrigo Arenas Arriola
      Rodrigo Arenas Arriola

      Does anybody knows if it is possible to save the email in outbox folder without sending?

      Thank you.

      Author's profile photo Former Member
      Former Member

      Hi Purvang,

      Have got same requirement where need to send image in the body of email with text (below image)

      Pls check below code ,i m  not getting image in the body  it is showing as X mark

      there is part of code mentioned above in the post which i have commented as it was showing junk character in Email

      Thanks in advance.

      REPORT ZTEST1.

      INCLUDE ZTEST1I.*all data declaration part done inside include

      *Create image in xstring form

      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/zlogo/xyz.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.

      CALL FUNCTION 'SSFC_BASE64_ENCODE'
      EXPORTING
      BINDATA                       
      = gv_content
      IMPORTING
      B64DATA                       
      = gv_content_64
      EXCEPTIONS
      SSF_KRN_ERROR                 
      = 1
      SSF_KRN_NOOP                  
      = 2
      SSF_KRN_NOMEMORY              
      = 3
      SSF_KRN_OPINV                 
      = 4
      SSF_KRN_INPUT_DATA_ERROR      
      = 5
      SSF_KRN_INVALID_PAR           
      = 6
      SSF_KRN_INVALID_PARLEN        
      = 7
      OTHERS                         = 8
      .
      IF SY-SUBRC <> 0.
      * Implement suitable error handling here
      ENDIF.

      *Attach image to HTML body
      l_filename
      = 'zlogo/xyz.jpg'.
      l_content_id
      = 'zlogo/xyz.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[].
      CLEAR ls_soli.

      *****************************************************HTML body content start**************************************************************************
      ls_soli
      = '<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xfa="http://www.xfa.org/schema/xfa-template/2.1/">' .
      APPEND ls_soli TO lt_soli.
      CLEAR ls_soli.

      ls_soli = '<html>'.
      APPEND ls_soli TO lt_soli.

      CLEAR ls_soli.

      ls_soli = '<body>'.
      APPEND ls_soli TO lt_soli.

      CLEAR ls_soli.

      *commented this part as was getting junk text in mail

      *ls_soli  = '< style="font-family:verdana;font-size:15px;">'  .
      *APPEND ls_soli TO lt_soli.
      *
      *CLEAR ls_soli.

      * lv_length = STRLEN( gv_content_64 ).
      * lv_len2 = lv_length / 255.
      * ls_soli = gv_content_64.
      * APPEND ls_soli TO lt_soli.

      *CLEAR ls_soli.
      *
      * DO lv_len2 TIMES.
      *
      * lv_len3 = 255 * sy-index.
      * IF lv_len3 <= lv_length.
      *  ls_solixr-line = gv_content_64(lv_len3).
      *      IF ls_solixr IS NOT INITIAL.
      *     MOVE ls_solixr-line TO ls_soli-line.
      *     APPEND ls_soli TO lt_soli.
      *     CLEAR lt_soli.
      *    ELSE.
      *       EXIT.
      *      ENDIF.
      *ELSEif lv_len3 > lv_length.
      *    EXIT.
      *ENDIF.
      *ENDDO.

      *end of commented code

      CLEAR ls_soli.

      ls_soli = '<img src="cid:zlogo/xyz.jpg">'.
      APPEND ls_soli TO lt_soli.
      clear ls_soli .

      ls_soli = '<BR> <BR> <BR> ' .

      APPEND ls_soli TO lt_soli.

      clear ls_soli .

      ls_soli = ' <p>   Dear Name1,  <BR> <BR>  the Following request requires your Attention: <BR> <BR> ' .

      APPEND ls_soli TO lt_soli.

      clear ls_soli .

      ls_soli = ' Request Number : <U> Ticket number </U> <BR> Request Type : Category <BR> Description: Test <BR> Current Status: Status <BR> </p> '  .

      APPEND ls_soli TO lt_soli.

      clear ls_soli .

      ls_Soli = ' <BR> <BR> <P1> <Strong> Action Team </Strong> </P1> <BR> <BR> '  .

      APPEND ls_soli TO lt_soli.

      clear ls_soli .

      ls_soli = '<h2 style="background-color:yellow;">' .

      APPEND ls_soli TO lt_soli.
      clear ls_soli .

      ls_soli = ' <P2> <font color = "#0000FF" size="+1" face="Arial,''Helvetica, sans-serif"   <BR>  This is an automatically generated message. Please do not reply to this address.  <BR> ' .

      APPEND ls_soli TO lt_soli.
      clear ls_soli .

      ls_soli = ' </body> ' .

      APPEND ls_soli TO lt_soli.
      clear ls_soli .

      ls_soli = ' </html> ' .

      APPEND ls_soli TO lt_soli.
      clear ls_soli .

      DATA : title type c LENGTH 100.

      CONCATENATE 'ticketnumber-status' 'requires your attention'  INTO title SEPARATED BY space.

      *CREATE OBJECT lo_mime_helper.

      CALL METHOD lo_mime_helper->set_main_html
      EXPORTING
      content
      = lt_soli
      filename
      = 'sapwebform.htm'      "filename for HMTL form
      description
      = 'Ticket Alert'"Title

      "Create HTML using BCS class and attach html and image part to it.
      l_subject
      = title"subject
      lo_doc_bcs
      = cl_document_bcs=>create_from_multirelated(
      i_subject
      = l_subject
      i_multirel_service
      = lo_mime_helper ).

      lo_bcs = cl_bcs=>create_persistent( ).

      "Create Document
      lo_bcs
      ->set_document( i_document = lo_doc_bcs ).

      "create Sender
      lo_sender
      = cl_cam_address_bcs=>create_internet_address( 'xyz@xyz.com' ).

      "Create Recipient
      lo_recipient
      = cl_cam_address_bcs=>create_internet_address( i_address_string = 'xyz@xyz.com' ).
      lo_bcs
      ->add_recipient( i_recipient = lo_recipient ).

      lo_bcs->send( ).
      COMMIT WORK AND WAIT.

      Author's profile photo Former Member
      Former Member

      A very good solution. Thanks for sharing.

      I am able to see the image in SOST but in outlook I am getting 2 attachments:-

      i) sapwebform.htm

      ii) photo.jpg.

      But I need the image in mail content. Please help.

      Author's profile photo Pradeep Kodinagula
      Pradeep Kodinagula

      Im facing the same problem, could you please share the solution if you found one.

      Thanks

      Author's profile photo Former Member
      Former Member

      Hi,

      same problem, did everyone found a solution?

      Thanks.

      Author's profile photo Former Member
      Former Member

       

      Hello.

      Please let me know if anyone found the solution for the same. I took the help of the blog above. It works perfectly if I open my emails in Web Browser but when I open it in Outlook , I get two attachments .

      Please let me know how to solve the issue.

      Thanks

      Author's profile photo Former Member
      Former Member

      Hi Purvang,

      Thanks for the documentation it is really good.

      I have also same requirement but when i try to execute the program the image is attached in the mail and not showing in body but a icon  with a cross sign is displayed in the body.

      Please help if you can. I am pasting my code below.

      Thanks in advance.

      REPORT ZTEST_IT.

      "For Mime Repository

      DATA : gv_mr_api TYPE REF TO if_mr_api, "mime repository object

              gv_content TYPE xstring,  "image in XSTRING

              is_folder TYPE boole_d,

              l_loio TYPE skwf_io.

      "source Code for image in mail body by Purvang Gandhi

      "Image to Xstring Table form

      DATA : l_obj_len      TYPE so_obj_len,

        lv_graphic_length TYPE tdlength,

              gr_xstr TYPE xstring,

              l_offset TYPE i,

              l_length TYPE i,

              l_diff TYPE i,

              ls_solix TYPE solix,

              lt_solix TYPE solix_tab.

      *Attach image to HTML body

      DATA: l_filename     TYPE string,

             l_content_id TYPE string.

      "for HTML content

        data : lt_soli        TYPE soli_tab,

               ls_soli TYPE soli.

      *Class for cobining HMTL & Image

      DATA : lo_mime_helper    TYPE REF TO cl_gbt_multirelated_service.

      *BCS class for sending mail

      data: lo_bcs            TYPE REF TO cl_bcs,

              lo_doc_bcs TYPE REF TO cl_document_bcs,

              lo_sender TYPE REF TO if_sender_bcs,

        lo_recipient      TYPE REF TO if_recipient_bcs,

              l_subject TYPE so_obj_des.

      "Create image in xstring form

      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/Happy.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 lt 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_happy.jpg'.

      l_content_id = 'img_happy.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[].

      CLEAR ls_soli.

      ls_soli = '<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xfa="http://www.xfa.org/schema/xfa-template/2.1/"><head></head>'.

      APPEND ls_soli TO lt_soli.

      CLEAR ls_soli.

      ls_soli = '<body>'.

      APPEND ls_soli TO lt_soli.

      "to apply font to HTML body content

      CLEAR ls_soli.

      CONCATENATE '<p><font size="4" face="Gabriola,Lucida Calligraphy,Comic Sans MS" color="red" fontStyle="italic"><i><b>Dear'

        'Employee Name' ', <br>' INTO ls_soli SEPARATED BY space.

      APPEND ls_soli TO lt_soli.

      "For displaying Image

      CLEAR ls_soli.

      ls_soli = '<br><img alt="[image]" src="cid:happy.jpg" /><br>'.

      APPEND ls_soli TO lt_soli.

      CLEAR ls_soli.

      CONCATENATE '<br>Regards,<br>' 'CEO Name' '<br>Team GINGER</b></i></font></p></body></html>'

                   INTO ls_soli SEPARATED BY space.

      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

      *    filename = 'sapwebform.htm'      "filename for HMTL form

           description = 'Birthday Greeting'"Title

      "Create HTML using BCS class and attach html and image part to it.

      l_subject = 'Birthday Greetings'(t01).  "subject

      lo_doc_bcs = cl_document_bcs=>create_from_multirelated( i_subject = l_subject i_multirel_service = lo_mime_helper ).

      lo_bcs = cl_bcs=>create_persistent( ).

      "Create Document

      lo_bcs->set_document( i_document = lo_doc_bcs ).

      "create Sender

      *lo_sender = cl_cam_address_bcs=>create_internet_address( 'xyz@abc.com' ).

      *

      ** Set sender

      *lo_bcs->set_sender( EXPORTING i_sender = lo_sender ).

      "Create Recipient

      lo_recipient = cl_cam_address_bcs=>create_internet_address( i_address_string = 'xyz@abc.com' ).

      lo_bcs->add_recipient( i_recipient = lo_recipient ).

           IF lo_bcs->send( ) IS INITIAL.

               ELSE.

               COMMIT WORK.

             ENDIF.

      WAIT UP TO 2 SECONDS.

         SUBMIT rsconn01 WITH mode = 'INT'

                       WITH output = 'X'

                       AND RETURN.

      *COMMIT WORK AND WAIT.

      Author's profile photo Pradeep Kodinagula
      Pradeep Kodinagula

      Im facing the same problem, could you please share the solution if you found one.

      Thanks

      Author's profile photo Former Member
      Former Member

      Hi,

      I am also getting the same issue, image is not being displayed in email body but a place holder with cross sign is being displayed. Also the image doesn't comes as an attachment. It would be of great help if someone can guide me through the solution.

      Thanks

      Author's profile photo Virgilio Israel Morales
      Virgilio Israel Morales

      It is a great information.

      Thanks,

      Author's profile photo Former Member
      Former Member

      Useful information..

      Thanks

      Author's profile photo Kasper Peters
      Kasper Peters

      Great example. Tested and worked. Thanks.

      Author's profile photo Former Member
      Former Member

      Hi Puvang,

      Thank you so much for the post.

      I was trying to fulfill a requirement where I need to send a Smartform ( Converted to PDF ) as attachment along with the mail body where there is logo in the signature section.

      The approach mentioned by you works perfectly for email body part.

      But the problem I face is the attachment handles by the below piece of code does not work.

      lo_doc_bcs1->add_attachment(

              i_attachment_type      'PDF'

              i_attachment_subject  gv_title

              i_attachment_size      =   lv_len
      i_att_content_hex 
      =   li_content_hex ).

      Can you suggest what could be done here.

      Regards,

      Rama Murthy

      Author's profile photo Virgilio Israel Morales
      Virgilio Israel Morales

      Hi Rama.

      Did you change the bin file to binary tab on previous steps?

      Generally below are the steps i made:

      1. i used the CONVERT_OTF function

      CALL FUNCTION 'CONVERT_OTF'

           EXPORTING

             format                = 'PDF'

             max_linewidth         = 132

           IMPORTING

             bin_filesize          = bin_size

             bin_file              = pdf_xstring

           TABLES

             otf                   = t_otf

             lines                 = t_pdf_tab

           EXCEPTIONS

             err_max_linewidth     = 1

             err_format            = 2

             err_conv_not_possible = 3

             OTHERS                = 4.


      2. Once i get the bin file, i changed the bin_file to binary tab with CMS_XSTRING_TO_BINARY

      DATA:  l_size      TYPE sood-objlen,

      CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'

               EXPORTING

                 buffer        = pdf_xstring

               IMPORTING

                 output_length = len_size

               TABLES

                 binary_tab    = pdf_content.

      MOVE len_size TO l_size.

      3.Finally you should be able to attach you document in the email with the same function you are using


      CALL METHOD l_document->add_attachment

               EXPORTING

                 i_attachment_type    = 'PDF'

                 i_attachment_size    = l_size

                 i_att_content_hex    = pdf_content.


      Hope this helps.


      Have a nice weekend.

      Author's profile photo Former Member
      Former Member

      Hi Virgilio,

      It worked thank you so much....!

      Regards,

      Murthy

      Author's profile photo Tanju Lise
      Tanju Lise

      Hi Murthy,

      I have got same problem .

      I saw your message when I check the sdn.

      So, please tell me first of what did you do ?

      I mean you when you use CONVERT OTF function you are saying PDF..

      You mean are your grafic  a PDF format  ?

      And did you do MIME Repository  working using se80?

      WouńĪld you please write me how can I start before writing this code  ?

      I will appreciate ...

      Thanks

      Regards

      Tanju

      Author's profile photo Tanju Lise
      Tanju Lise

      Hi Purvang,

      Great working, well done ...

      Please let me ask a question for you .

      I am attaching PDF files and sending , there is no any problem.

      But my problem is there is jpg files and PDF files sending together.

      I am using the function 'SO_DOCUMENT_SEND_API1'  ..

      So My question, how can I send together ?

      I mean how can start first of all ?

      Am I use MIME Repository ?

      May I use MIME Repository and SO_DOCUMENT_SEND_API1 together ?

      Is this right ?

      Or is this wrong how can I start ?

      Well, in fact I opened a new incident in SDN, but unfortunately it was removed cause of rules.

      I did not understand why ?

      If you help me I am reallly appreciate 

      Regards

      Tanju

      Author's profile photo siva 9533
      siva 9533

      Hi ,

      it is working fine with one IMAGE,but it is not working with multiple IMAGES . Can some one help how to work with multiple images using MIME helper .

      Regards,

      Siva Krishna

      Author's profile photo Tanju Lise
      Tanju Lise

      Thank You Siva,

      I got it,

      Greetings from Istanbul

      Tanju

      Author's profile photo siva 9533
      siva 9533

      Hi Tanju,

      you got it means , you are able to get multiple images using MIME helper?

      if yes

      can you please help me to get it.

      Regards,

      Siva

      Author's profile photo siva 9533
      siva 9533

      I tried in different way to attach multiple images but those are working fine in outlook but not working properly in SOST and Webmail ( Mail Box in Internet explorer ) are not working fine.

      Please open the below link for more details.

      Email Preview in SOST

      Author's profile photo Tanju Lise
      Tanju Lise

      Dear Siva,

      http://scn.sap.com/thread/3783877

      Siva, This is my incident and one of my collegue Eitan helped me ...

      Please check it ...

      Is there any problem, we can speak ...

      Regards

      Tanju

      Author's profile photo siva 9533
      siva 9533

      Many many thanks Tanju.

      it worked as what I have expected.

      Thank you very much appreciated your help.

      Regards,

      Siva Krishna

      Author's profile photo Tanju Lise
      Tanju Lise

      You are welcome Siva,

      We are friend, we are collegue, ...

      Take care of yourself

      Tanju

      Author's profile photo siva 9533
      siva 9533

      Hi Tanju,

      I have one more last request , Email body is showing perfectly in English language where it it not showing correctly in other languages .

      Example :

      Text in Mail :-

      Text in English  :   Thank you for your           

      Text in German  :  vielen Dank für Ihre

      Text in SOST  Display :-

      Text in English  :   Thank you for your           

      Text in German  :  vielen Dank für Ihre

      Regards,

      Siva Krishna


      Author's profile photo Tanju Lise
      Tanju Lise

      Hi Siva,

      It seems like a font problem ...

      Would you please try another font ?

      Regards

      Tanju

      Author's profile photo siva 9533
      siva 9533

      I am using Arial font for both English and German language . is there will be any notes  from SAP for fonts ?

      Author's profile photo Tanju Lise
      Tanju Lise

      Hi Siva,

      I foung this sdn note ...

      https://scn.sap.com/thread/369787

      I hope it helps ...

      Regards

      Tanju

      Author's profile photo Former Member
      Former Member

      I am unable to find Source code attachment. Could you please share or let know where i can see attachment in same thread.

      Author's profile photo Ravi Kumar
      Ravi Kumar

      Hi Gurus,

      I have imported the image in MIME Repository and used in the email attachment. Everything is working fine, and image is displaying in Email (using this in CRM WebUI flow logic)when I execute the flow.

      But when the Business users in CRM WebUI execute the logic, the image is not rendering for some users.

      Is there any authorization issue or any other? Please help!!!

       

      Thanks in advance.

      Author's profile photo Former Member
      Former Member

      Hi All,

       

      I can see in the blog, it is mentioned that code is attached in text file. However i do not see the text attachment.

      Can anyone please help me with the full code for this?

      Author's profile photo Ravi Kumar
      Ravi Kumar

      Anyone solved Multi-Image in Email Body using MIME helper? Please help Very Urgent!!!!

       

      Author's profile photo Gopalkrishna Baliga
      Gopalkrishna Baliga

      Hi Purvang & Shnakar,

      I am also facing the problem where in image is not getting displayed in the outlook.

      Can you please share the solution for this?

      Thanks

      Gopal

       

       

       

      Author's profile photo Shai Sinai
      Shai Sinai

      a long time has passed, but I saw that this is a common issue/question, so I decided to write down the solution:

      The problem lies in method lo_mime_helper->set_main_html.
      You must leave the filename empty.
      In case filename isn't empty, Microsoft Outlook will interrupt it as an attachment instead of e-mail body.

      Author's profile photo oguz ilhan
      oguz ilhan

      Hello

      I tried many ways to send an image in body but it still doesn t appear , I applied all steps correctly but no result I send all html to email address but image still  = X

       

      my code is here please help

       


      SPAN {
      font-family: ‚ÄúCourier New‚ÄĚ;
      font-size: 10pt;
      color: #000000;
      background: #FFFFFF;
      }
      .L0S31 {
      font-style: italic;
      color: #808080;
      }
      .L0S32 {
      color: #3399FF;
      }
      .L0S33 {
      color: #4DA619;
      }
      .L0S52 {
      color: #0000FF;
      }
      .L0S55 {
      color: #800080;
      }
      .L0S70 {
      color: #808080;
      }
      REPORT ZBW_HBDAY.

      DATA:
      *- Structure to hold Output Details in delimited format
      gf_output_soli TYPE  soli,
      *- Structure to hold Imported Object Components
      gf_objpack     TYPE sopcklsti1,
      *- Structure to hold data in single line format
      gf_objhead     TYPE solisti1,
      *- Structure to hold data in single line format
      gf_objtxt      TYPE solisti1,
      *- Structure to hold data for API Recipient List
      gf_reclist     TYPE somlreci1,
      *- Structure to hold  email data
      gf_doc_chng    TYPE sodocchgi1,
      *- Internal Table to hold Output Details in delimited format
      gt_output_soli TYPE TABLE OF soli,
      *- Internal Table to hold Imported Object Components
      gt_objpack     TYPE TABLE OF sopcklsti1,
      *- Internal Table to hold data in single line format
      gt_objhead     TYPE TABLE OF solisti1,
      *- Internal Table to hold data in single line format
      gt_objtxt      TYPE TABLE OF solisti1,
      *- Internal Table to hold data for API Recipient List
      gt_reclist     TYPE TABLE OF somlreci1.

      * Data Declarations
      DATA: LT_MAILSUBJECT     TYPE SODOCCHGI1.
      DATA: LT_MAILRECIPIENTS  TYPE STANDARD TABLE OF SOMLREC90 WITH HEADER LINE.
      DATA: LT_MAILTXT         TYPE STANDARD TABLE OF SOLI      WITH HEADER LINE.

      DATA: LT_MAILSUBJECT_2     TYPE SODOCCHGI1.
      DATA: LT_MAILRECIPIENTS_2  TYPE STANDARD TABLE OF SOMLREC90 WITH HEADER LINE.
      DATA: LT_MAILTXT_2         TYPE STANDARD TABLE OF SOLI      WITH HEADER LINE.

      DATA: BEGIN OF GT_ITAB OCCURS 0,
      usrid_long¬†like¬†¬†pa0105‚Äďusrid_long.
      DATA: END OF GT_ITAB,

      LS_ITAB LIKE LINE OF GT_ITAB.

      data : date(2) type c,
      month(2) type c,
      year(4) type c.

      date¬†=¬†sy‚Äďdatum+6(2).
      month¬†=¬†sy‚Äďdatum+4(2).
      year¬†=¬†sy‚Äďdatum+0(4).

      SELECT
      distinct
      p05~usrid_long
      FROM PA0002 as p2 INNER JOIN   pa0000 as p0 on p2~pernr = p0~pernr
      inner join pa0105 as p05 on p05~pernr = p0~pernr
      into table gt_itab
      where¬†p2~gbmon¬†=¬†month¬†¬†¬†¬†and¬†¬†p2~gbtag¬†=¬†date¬†and¬†p05~usrid_long¬†<>¬†‚Ä̬†.

      *loop at gt_itab.

      * Recipients
      *LT_MAILRECIPIENTS-REC_TYPE¬†¬†=¬†‚ÄėU‚Äô.
      *LT_MAILRECIPIENTS-RECEIVER = gt_itab-usrid_long.
      *APPEND LT_MAILRECIPIENTS .
      *CLEAR LT_MAILRECIPIENTS .

      LT_MAILRECIPIENTS‚ÄďREC_TYPE¬†¬†=¬†‚ÄėU‚Äô.
      LT_MAILRECIPIENTS‚ÄďRECEIVER¬†=¬†‚Äė<private information removed by moderator>‚Äô.
      LT_MAILRECIPIENTS‚ÄďBLIND_COPY¬†=¬†‚ÄėX‚Äô.
      APPEND LT_MAILRECIPIENTS .

      *ENDLOOP.

      DATA: gv_mr_api TYPE REF TO if_mr_api.

      DATA is_folder TYPE boole_d.
      DATA l_current TYPE xstring.
      DATA l_loio TYPE skwf_io.

      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/dogum_gunu.jpg‚Äô
      IMPORTING
      e_is_folder        = is_folder
      e_content          = l_current
      e_loio             = l_loio
      EXCEPTIONS
      parameter_missing = 1
      error_occured      = 2
      not_found          = 3
      permission_failure = 4
      OTHERS             = 5.

      *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/dogum_gunu.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

      DATA :         gv_content TYPE xstring.

      DATA : l_obj_len      TYPE so_obj_len,
      lv_graphic_length TYPE tdlength,
      gr_xstr TYPE xstring,
      l_offset TYPE i,
      l_length TYPE i,
      l_diff TYPE i,
      ls_solix TYPE solix,
      lt_solix TYPE solix_tab.

      DATA: l_filename     TYPE string,
      l_content_id TYPE string,
      gv_content_64 type string,
      lv_length type string,
      lv_len2 type i,
      lv_len3 type i.

      data : lt_soli        TYPE soli_tab,
      ls_soli TYPE soli.

      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¬†‚Ästl_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.

      *¬†¬†CALL¬†FUNCTION¬†‚ÄėSSFC_BASE64_ENCODE‚Äô
      *    EXPORTING
      *      bindata                        = l_current
      *   IMPORTING
      *     b64data                        = b64data.
      *  IF sy-subrc <> 0.
      *  ENDIF.

      *CALL¬†FUNCTION¬†‚ÄėSSFC_BASE64_ENCODE‚Äô
      *EXPORTING
      *BINDATA                        = gv_content
      *IMPORTING
      *B64DATA                        = gv_content_64
      *EXCEPTIONS
      *SSF_KRN_ERROR                  = 1
      *SSF_KRN_NOOP                   = 2
      *SSF_KRN_NOMEMORY               = 3
      *SSF_KRN_OPINV                  = 4
      *SSF_KRN_INPUT_DATA_ERROR       = 5
      *SSF_KRN_INVALID_PAR            = 6
      *SSF_KRN_INVALID_PARLEN         = 7
      *OTHERS                         = 8
      *.
      *IF SY-SUBRC <> 0.
      ** Implement suitable error handling here
      *ENDIF.

      *Attach image to HTML body
      l_filename¬†=¬†‚Äėdogum_gunu.jpg‚Äô.
      l_content_id¬†=¬†‚Äėdogum_gunu.jpg‚Äô.

      DATA : lo_mime_helper    TYPE REF TO cl_gbt_multirelated_service.

      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[].
      CLEAR ls_soli.

      *****************************************************HTML body content start**************************************************************************
      ls_soli¬†=¬†‚Äė<html¬†xmlns=‚ÄĚhttp://www.w3.org/1999/xhtml‚Ä̬†xmlns:xfa=‚ÄĚhttp://www.xfa.org/schema/xfa-template/2.1/‚ÄĚ>‚Äô¬†.
      APPEND ls_soli TO lt_soli.
      CLEAR ls_soli.

      ls_soli¬†=¬†‚Äė<html>‚Äô.
      APPEND ls_soli TO lt_soli.

      CLEAR ls_soli.

      ls_soli¬†=¬†‚Äė<body>‚Äô.
      APPEND ls_soli TO lt_soli.

      CLEAR ls_soli.

      *
      *
      *
      *
      *ls_soli¬†¬†=¬†‚Äė<style=‚ÄĚfont-family:verdana;font-size:15px;‚ÄĚ>‚Äô¬†¬†.
      *APPEND ls_soli TO lt_soli.
      *
      *CLEAR ls_soli.
      *
      * lv_length = STRLEN( gv_content_64 ).
      * lv_len2 = lv_length / 255.
      * ls_soli = gv_content_64.
      * APPEND ls_soli TO lt_soli.
      *
      *CLEAR ls_soli.
      *
      * DO lv_len2 TIMES.
      *
      * lv_len3 = 255 * sy-index.
      * IF lv_len3 <= lv_length.
      *  ls_soli-line = gv_content_64(lv_len3).
      *      IF ls_soli IS NOT INITIAL.
      *     MOVE ls_soli-line TO ls_soli-line.
      *     APPEND ls_soli TO lt_soli.
      *     CLEAR lt_soli.
      *    ELSE.
      *       EXIT.
      *      ENDIF.
      *ELSEif lv_len3 > lv_length.
      *    EXIT.
      *ENDIF.
      *ENDDO.
      *
      *
      *
      *CLEAR ls_soli.

      ls_soli¬†=¬†‚Äė<br><img¬†src=‚ÄĚcid:dogum_gunu.jpg‚Ä̬†/>‚Äô.
      APPEND ls_soli TO lt_soli.
      clear ls_soli .

      ls_soli¬†=¬†‚Äė<BR>¬†<BR>¬†<BR>¬†‚Äė¬†.

      APPEND ls_soli TO lt_soli.

      clear ls_soli .

      ls_soli¬†=¬†‚Äė¬†<p>¬†¬†¬†Dear¬†Name1,¬†¬†<BR>¬†<BR>¬†¬†the¬†Following¬†request¬†requires¬†your¬†Attention:¬†<BR>¬†<BR>¬†‚Äė¬†.

      APPEND ls_soli TO lt_soli.

      clear ls_soli .

      ls_soli¬†=¬†‚Äė¬†Request¬†Number¬†:¬†<U>¬†Ticket¬†number¬†</U>¬†<BR>¬†Request¬†Type¬†:¬†Category¬†<BR>¬†Description:¬†Test¬†<BR>¬†Current¬†Status:¬†Status¬†<BR>¬†</p>¬†‚Äė¬†¬†.

      APPEND ls_soli TO lt_soli.

      clear ls_soli .

      ls_Soli¬†=¬†‚Äė¬†<BR>¬†<BR>¬†<P1>¬†<Strong>¬†Action¬†Team¬†</Strong>¬†</P1>¬†<BR>¬†<BR>¬†‚Äė¬†¬†.

      APPEND ls_soli TO lt_soli.

      clear ls_soli .

      ls_soli¬†=¬†‚Äė<h2¬†style=‚ÄĚbackground-color:yellow;‚ÄĚ>‚Äô¬†.

      APPEND ls_soli TO lt_soli.
      clear ls_soli .

      ls_soli¬†=¬†‚Äė¬†<P2>¬†<font¬†color¬†=¬†‚Äú#0000FF‚Ä̬†size=‚ÄĚ+1‚Ä≥¬†face=‚ÄĚArial,‚ÄĚHelvetica,¬†sans-serif‚Ä̬†¬†¬†<BR>¬†¬†This¬†is¬†an¬†automatically¬†generated¬†message.¬†Please¬†do¬†not¬†reply¬†to¬†this¬†address.¬†¬†<BR>¬†‚Äė¬†.

      APPEND ls_soli TO lt_soli.
      clear ls_soli .

      ls_soli¬†=¬†‚Äė¬†</body>¬†‚Äė¬†.

      APPEND ls_soli TO lt_soli.
      clear ls_soli .

      ls_soli¬†=¬†‚Äė¬†</html>¬†‚Äė¬†.

      APPEND ls_soli TO lt_soli.
      clear ls_soli .

      DATA : title type c LENGTH 100.

      CONCATENATE¬†‚Äėticketnumber-status‚Äô¬†‚Äėrequires¬†your¬†attention‚Äô¬†¬†INTO¬†title¬†SEPARATED¬†BY¬†space.

      *CREATE OBJECT lo_mime_helper.

      CALL METHOD lo_mime_helper->set_main_html
      EXPORTING
      content = lt_soli
      filename¬†=¬†‚Äėsapwebform.htm‚Äô
      description¬†=¬†‚ÄėTicket¬†Alert‚Äô.

      data: lo_bcs            TYPE REF TO cl_bcs,

      lo_doc_bcs TYPE REF TO cl_document_bcs,

      lo_sender TYPE REF TO if_sender_bcs,

      lo_recipient      TYPE REF TO if_recipient_bcs,

      l_subject TYPE so_obj_des.

      “Create HTML using BCS class and attach html and image part to it.
      l_subject = title.  “subject
      lo_doc_bcs = cl_document_bcs=>create_from_multirelated(
      i_subject = l_subject
      i_multirel_service = lo_mime_helper ).

      lo_bcs = cl_bcs=>create_persistent( ).

      “Create Document
      lo_bcs->set_document( i_document = lo_doc_bcs ).

      “create Sender
      lo_sender¬†=¬†cl_cam_address_bcs=>create_internet_address(¬†‚Äė<private information removed by moderator>‚Äô ).

      “Create Recipient
      lo_recipient¬†=¬†cl_cam_address_bcs=>create_internet_address(¬†i_address_string¬†=¬†‚Äė<private information removed by moderator>‚Äô ).
      lo_bcs->add_recipient( i_recipient = lo_recipient ).

      lo_bcs->send( ).
      COMMIT WORK AND WAIT.

      Author's profile photo Prakasha BadeGowda
      Prakasha BadeGowda

      Hello Experts,

      I am facing one issue when copying inbound to outbound mail.

      Everything is working when inbound mail have text format. We are facing issues when we copy inbound mail image to outbound mail.

      I am using SAP FM: CRM_ERMS_MAIL_SEND  to send outbound mail.

      Any idea how copy inbound mail image to outbound mail.