Automate Email testing


Looking to read the content of the email body? Do you wish to read the body of the email and verify its content?


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.

Before using this keyword, let's review the steps to enable the necessary settings on your Gmail account.

1. Click the Settings tab of your Gmail.



2. Enable the POP and IMAP settings by selecting the "Forwarding and POP/IMAP" tab and choosing the "Enable POP and IMAP" radio buttons, as illustrated in the image above.

3. After enabling the settings, save the changes by clicking on the "Save Changes" button at the bottom.

4. To create an App Password, click "Manage Google Account." 



5. Go to the Security tab and enable the Two-Step Verification.



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

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



8. After selecting the App and Device, click on the "Generate" button. 



9. Upon generation, a password will be created, and you can view it after logging into your account. 


10. Save the generated App Password in a Notepad as it will be used later in the Password field for the "GetMailBody" Opkey keyword. 

11. The next step involves editing the security file of Java under the Opkey Agent installed location. Navigate to the C Drive, go to Program Files (x86) > SSTS > Opkey > Opkey Execution Agent > Java > 64 > jdk > jre > lib > Security. 

12. Open Notepad++ and add the previously provided path to the security file. 


13. Edit the Security File to the Notepad++


14. On Notepad++ put a comment on the line number 723, 724, and 725 and click on Save. 


15. Next, 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 –"your username"

Password – “your password”

Subject – “Subject line of the Email”

MaximumMailCount – “100-200”

IgnoreCase – False

FolderPath - [Gmail]/All Mail

OnlyUnread - False


16. click on OK and Save the details.

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


‍This is how you can verify the content of the email.

Explore more Opkey features by clicking Here. 

To learn more about using such keywords in Opkey, you can visit and enroll in our Opkey series course.

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 at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article