Skip to main content

How to test the text content of email or SMS

Learn how to test the text content of email or SMS with SMSByrd.

HTML and text content within an email Most email sent today is HTML-based, however an email will often contain a plain text alternative for older mail clients, which is what this page relates to. Learn how to work with the HTML content of an email.

//add css

Before you begin

The examples shown below are based on two key assumptions:

  1. That you have already create a basic automated test using our getting started guides.
  2. You have a chosen assertion library that you will use to test the values shown below.

Accessing the text

The text content of email or SMS message can be accessed via the text.body property of a message.

//code snippet

Working with the content

This section describes some of the most common use cases related to the content of an email or SMS message. You should also refer to the guides on working with automatically-extracted content such as links and images.

Checking if message contains a string

//code snippet

Finding a 6-digit code

Note: We recommend using SMSByrd’s built-in verification code detection. However, you can also write your own regular expressions to extract values from within your content.

The example below shows how to extract a 6-digit numeric code from a message.

//code snippet

Finding an 8-digit alphanumeric code

In this example, an 8-digit code, consisting of 2 letters, followed by 6 numbers is extracted.

//code snippet