Get Mail Body

Do you come across test cases where you need to verify the content of an email?

Opkey’s keyword GetMailBody will assist you in reading the body of the mail with the provided subject line.

Let us first have a look at the steps to enable the Settings on your Gmail to proceed to work with this keyword. 

Click on the Settings tab of your Gmail.


Select the Forwarding and POP/IMAP tab and click on the Enable POP and IMAP radio buttons as shown in the image above.

Once the settings are enabled, click on the Save Changes button present at the bottom.

Next, you need to create the App Password. To do so click on the Manage Google Account.


You need to go to the Security tab and enable the Two-Step Verification.

Next, click on the App Password and select the App.


Adjacent to the App is the Device. Click on the Device.


Once the App and Device is selected, you’ll have to click on the Generate button.


It will Generate a Password, which you’ll be able to view post logging into your account.

You need to save the Generated App Password in a Notepad which will further be used in the Password filed in the GetMailBody Opkey keyword.

Next step is to edit the security file of Java under Opkey Agent installed location. On your C Drive, go to Program Filesx86 > SSTS > Opkey > Opkey Execution Agent > Java > 64 > jdk > jre > lib > Security > 

Open Notepad++ and add the above-shared path and add to Notepad ++ 

You need to edit the Security File to the Notepad++

On Notepad++ put a comment on lines 723, 724, 725 and click on Save. 

Next you need to Log In to Opkey and Create a Test Case. 

In the Test Case, add the Keyword GetMailBody and enter the below details in the Input Parameter. 

Protocol – imap

Host –

Port – 993

Username –

Password – “your password”

Subject – “Subject line of the Email”

MaximumMailCount – “100-200”

IgnoreCase – False

FolderPath - [Gmail]/All Mail

OnlyUnread - False

Once all the data is entered, click on Ok and Save the details.

On execution, you’ll be able to view the content of the mail body in the Output Data.

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons

Feedback sent

We appreciate your effort and will try to fix the article