Skip to Content
Author's profile photo Former Member

Send E-mail in HTML format with dynamic e-mail body content

Applies to:

SAP Netweaver, ABAP, Email, standard text


This tutorial will take you step by step process to develop ABAP program which will send E mail in HTML format. The email body content is maintained separately in Std. text object; so that it can be maintained independent of Program.

With this; email is generated in HTM format which is more asthetic than a RAW format. Email body can be formatted with all rich text properties like bold, italic fonts, text sizes, tables, etc.

Additionally email body content can be changed without changing the ABAP program; since it is maintained separately in standard text. Program modularization & ease of maintenance can be achieved.

Author:        Amit Talekar

Company:   Capgemini India

Created on: 23rd July 2012

Create Standard text object

Create standard text object from /SO10


     Maintain text with HTML tags

     In this example HTML tags for table structure are maintained.


    For dynamic contents; program global variables are used


    Read std. text in ABAP Program

     Call FM READ_TEXT

     Using Standard Function module READ_TEXT read Std. text in the program.



     LS_HEAD contains Header data and LT_LINES contains text maintained in the object.



     Call FM to replace variables in std. text with actual values.



     FM TEXT_SYMBOL_REPLACE returns LT_LINES with values (passed as program global variables).


    Send E-mail

     Prepare E-mail subject & E-mail body


     Call Std. FM to send E-mail in HTML format


   Check the output in MS-Outlook


Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Thomas Zloch
      Thomas Zloch

      Please try posting code as text and not screen dumps, so people can easier try out what you are suggesting.

      Also I would rather use the newer functionality of the CL_BCS class for sending mails than the older SO_NEW_DOCUMENT... function modules.


      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Hello Thomas,

      Thanks for pointing it out. In future I will take care of the same.


      Author's profile photo Madhu Vadlamani
      Madhu Vadlamani

      Hi Amit,

      Good one.



      Author's profile photo Former Member
      Former Member

      Hi Amit , thanks for the share ,

      i am hoping you can give me some guidance on the following :

      i have a user requirement to replace the following functionality we provide , the user when working with certain transactions have the option to send email

      we provide the user with a standard text editor (like S000) which then use the text contents to be populated as the email body text with the outgoing email

      now we want to provide them wth the ame functionality but use a HTML editor allwoingthe user much more functionality like bold , colour tools etc

      can you help me please

      thank you


      Author's profile photo Bruno Esperança
      Bruno Esperança

      Excellent, thanks!

      Best regards,


      Author's profile photo Denis Muzhzhukhin
      Denis Muzhzhukhin


      to be honest, it's better to use XSLT transformations to build HTML letters.

      Kind regards,


      Author's profile photo Former Member
      Former Member


      I have a similar feeling. There are multiple ways to create texts in XML-based format.

      And I'm not so convinced about this: "Program modularization & ease of maintenance can be achieved."
      How ease if maintanance can be achieved when you create manually HTML code in standard text ....

      Regards, Radek

      Author's profile photo Florin Wach
      Florin Wach

      I was looking for a simple-to-be-used example for reading a Standard text from SO10 and replace the symbols from the current main program.

      This blog helped me a lot here, although there was one piece missing for me, and another small correction:

      - The program (sy-repid) needs to be transferred an the call to the replace-FM, otherwise it doesn't replace any program symbols

      - The replace-FM doesn't need the sy-tfill. When not provided, it uses the complete table.

      Thanks and best regards


      Author's profile photo Veena S
      Veena S


      Is there any way to get the changed values of mail body in Outlook when it come back to SAP?

      We are doing offline approval process using Outlook. In that case, User has to enter the OTP in a text box given in mail body. How can we get this OTP value when the user replies to mail?

      Any help is appreciated.



      Author's profile photo Bindu Sree
      Bindu Sree


      Followed the same process  but the content in standard text is not displaying.

      Please help.