Get Mail Body

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

OpKey's "GetMailBody" keyword aids in reading the body of an email with the provided subject line.

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


Click the Settings tab of your Gmail.

 

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.

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


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

 

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.

 

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

 

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

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

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. 


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

Edit the Security File to the Notepad++

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

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 – imap.gmail.com

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

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.

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

Simplify your testing journey with Opkey.

Click Here to learn more about Opkey features.


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
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article