OXYGEN
HomeGitHubReleasesCommunity
  • Welcome to Oxygen
  • About
    • What is Oxygen?
    • Getting Started (Videos)
      • Oxygen IDE Controls Overview
      • Recording a Web Test
      • Oxygen Commands Explained
    • Getting help
  • Download and work with Oxygen
    • Download & Installation
      • Oxygen IDE Installation
      • Oxygen for Mobile Installation
      • Oxygen for Windows Desktop Automation Setup
      • Oxygen for Mac Installation
        • Mac Installation Troubleshooting
      • Oxygen CLI Installation
      • Java Installation Instructions
      • Recording Troubleshooting
    • Start working with Oxygen
      • Getting Started - Web
        • Introduction - Web Testing
        • Recording a Web Test
        • Creating a Web Test
        • Sample Project - Web Test
      • Getting Started - Mobile
        • Introduction - Mobile Testing
        • Recording a Test on Mobile
        • Creating a Test - Mobile
        • Sample Project - Mobile
      • Getting Started - Oxygen for Windows Desktop Automation
      • Getting Started- Oxyge CLI
        • Running a Test Script on Windows
        • Running Multiple Tests (Suites) on Windows
    • Oxygen Modules
      • assert
      • date
      • db
      • email
      • eyes
      • http
      • log
      • mailinator
      • mob
      • pdf
      • proxy
      • serial
      • shell
      • soap
      • twilio
      • utils
      • web
      • win
    • Test Parameters
  • Cloud Providers
    • Sauce Labs
    • Lambda Test
    • TestObject
  • Advanced programming in Oxygen
    • Project Configuration
    • Locating Elements
    • Page Objects
    • Environments
    • Code Components
Powered by GitBook
On this page
  • getLastEmail
  • init
  • send

Was this helpful?

  1. Download and work with Oxygen
  2. Oxygen Modules

email

Provides methods for working with email via IMAP.

getLastEmail

Retrieves last unseen email.

** Usage example:**

email.init('[YOUR_EMAIL]@gmail.com', 'password', 'imap.gmail.com', 993, true, 3000);
var mail = email.getLastEmail(60, 'email subject', 5000);
log.info(mail);

if(r.attachments && r.attachments.length > 0){
   const fs = require('fs');
   r.attachments.map((attachment) => {
   	let fileDescriptor;
   	try{
   		fileDescriptor = fs.openSync(attachment.filename, 'w');
   	} catch(e) {
   		throw 'could not open file: ' + e;
   	}
   	
   	try{
   		fs.writeFileSync(fileDescriptor, attachment.data);
   	} catch(e) {
   		throw 'error writing file: ' + e;
   	}
   	
   	fs.closeSync(fileDescriptor);
   });
}

Parameters:

Name
Type
Description

sinceMinutes

Number

Search for emails received since the specified amount of minutes into past.

subject

String|Regex

Return email matching the specified subject.

timeout

Number

Timeout (in milliseconds) for waiting for the message to arrive.

Returns:

Object - Email body, text, textAsHtml, attachments if any, and TO, FROM, SUBJECT, DATE headers.

init

Set email connection details.

Parameters:

Name
Type
Description

user

String

Username (e.g. 'your@email.address').

password

String

Password.

host

String

Host name (e.g. 'imap.gmail.com').

port

Number

Port number (e.g. 993).

tls

Boolean

true to use TLS, false otherwise.

authTimeout

Number

optional Authentication timeout in milliseconds.

enableSNI

Boolean

optional Enable sending SNI when establishing the connection. This is required for some mail servers. Default is false.

send

Send email using SMTP.

Parameters:

Name
Type
Description

to

String|Array

Receiver's email address.

subject

String

Email subject.

content

String

Email body as a plain text.

html

String

optional Optional, Email body as HTML.

PreviousdbNexteyes

Last updated 8 months ago

Was this helpful?