# HTML content of an email
> [!WARNING]
> Most email sent today is HTML-based, however, an email may also contain a plain text alternative for older mail clients. Learn how to work with text content of an email.
## Before you begin
The examples shown below are based on two key assumptions:
1. You have already created a basic automated test using our [getting started guides](/docs/automation).
2. You have a chosen assertion library that you will use to test the values shown below.
## Accessing the HTML content
An email’s HTML body can be accessed via the `html.body` property of a message.
```nodejs
console.log(message.html.body) // "
html->body); // "
org.jsoup
jsoup
1.13.1
```
```csharp
dotnet add package HtmlAgilityPack
```
```ruby
gem install nokogiri
```
```php
// Not required, skip to next step
```
```go
go get github.com/PuerkitoBio/goquery
```
### Import the library in your code
Next, reference the library in your code:
```nodejs
const { JSDOM } = require('jsdom')
```
```python
from bs4 import BeautifulSoup
```
```java
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;
```
```csharp
using HtmlAgilityPack;
```
```ruby
require 'nokogiri'
```
```php
// Not required, skip to next step
```
```go
import (
"github.com/PuerkitoBio/goquery"
)
```
### Find the target element
In this example, we want to extract the verification code from the HTML below:
```html
To activate your account, enter this code:
542163
```
To do this, we pass the email’s HTML body into our library, then find the element we need and access the 6-digit access code within:
```nodejs
const dom = new JSDOM(message.html.body);
const el = dom.window.document.querySelector('.verify-code');
const verificationCode = el.textContent;
console.log(verificationCode); // "542163"
```
```python
dom = BeautifulSoup(message.html.body, 'html.parser')
el = dom.find('.verify-code')
verification_code = el.text
print(verification_code) # "542163"
```
```java
Document doc = Jsoup.parse(message.html().body());
Elements elements = doc.getElementsByTag(".verify-code");
String verificationCode = elements.get(0).text();
System.out.println(verificationCode); // "542163"
```
```csharp
var doc = new HtmlDocument();
doc.LoadHtml(message.Html.Body);
// Find element using xpath
var node = doc.DocumentNode.SelectSingleNode("//*[contains(@class, 'verify-code')]")
var verificationCode = node.InnerText;
Console.WriteLine(verificationCode); // "542163"
```
```ruby
@doc = Nokogiri::HTML(message.html.body)
el = @doc.css(".verify-code")
verification_code = el.text
puts verification_code # "542163"
```
```php
$doc = new DOMDocument();
$doc->loadHTML($message->html->body);
$cssClass = 'verify-code';
$xpath = new DomXPath($doc);
$matches = $xpath->query("//*[contains(concat(' ', normalize-space(@class), ' '), ' $cssClass ')]");
$verificationCode = $matches[0]->textContent;
print($verificationCode); // "542163"
```
```go
htmlBytes := strings.NewReader(email.Html.Body)
doc, _ := goquery.NewDocumentFromReader(htmlBytes)
sel := doc.Find(".verify-code")
for i := range sel.Nodes {
single := sel.Eq(i)
verificationCode := single.Text()
fmt.Print(verificationCode) // "542163"
}
```
#### See also
- [Plain text content](/docs/automation/text-content)