Creating HTML e-mail

In this recipe, we will see how we can display the body of our e-mail in HTML to our messages body. We will see how text may be displayed in bold, in various colors, for example, red and how to set the background color of the e-mail body. We will copy the program shown in the first recipe and make few changes in it. The detail of HTML coding is beyond the scope of this book. The focus of the recipe will be on how basic HTML code is shown in the e-mail body.

How to do it...

We will now carry out the steps shown as follows;

  1. For the email_text internal table, we will append a number of rows. Each row appended will correspond to the lines of the HTML code. We will specify a background color for the e-mail body. Then on the first line, we will write a text Dear Sir in font size = 2. On the next line, we will write text in red color. Finally, on the last line we write text in bold format, as shown in the following screenshot:
    How to do it...
  2. The e-mail text will then be used to create the document that will later be attached to the send request. While calling the create_document method, the type of document specified will be HTML, rather than RAW in the previous recipes.
    How to do it...

How it works...

We made a few changes in the program. First, we entered the entire HTML code in the form of an internal table. It should be made sure that the entire code is enclosed within <HTML> and </HTML> tags.

In the next step, the appropriate type (HTML) of the document that is to be created is specified for the method create_document and the internal table containing the HTML coding is passed. The rest of the coding remains the same. The e-mail generated from the program appears as shown in the following screenshot:

How it works...

We have used only one font size. However, within the HTML body we may have different font sizes.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.143.17.27