We'll be using modified PowerShell script from this repository:

https://github.com/arveds/Send-O365MailMessage

Unzip attached sendemail.zip and put sendemail.ps1 into the folder of your test.

To call this script add a function to User.js:

function SendDataFile(/**string*/ fileName)
{
	var clientId = Global.GetProperty('ClientId');
	var username = Global.GetProperty('UserName');
	var password = Global.DoDecrypt(Global.GetProperty('Password'));
	var to = username;
	var subject = "Test Email";
	var body = "Email body";

	var cmdLine = 'powershell .exe -WindowStyle Hidden -File sendemail.ps1 -clientId "' + clientId + 
				  '" -username "' + username + '" -password "' + password + 
				  '" -to "' + to + '" -subject "' + subject + '" -body "' + body + 
				  '" -attachmentPath "' + Global.GetFullPath(fileName) + '"';
	
	Global.DoLaunch(cmdLine);
}

In this example we are sending an email with attachment. Modify the function to meet your needs.

Important Notes

Most tricky part is to register ClientId in Azure Portal. Read the guidelines here.

Also to run sendemail.ps1 you will need to install MSAL.ps into 32-bit version of PowerShell.

1. From Administrator command prompt run PowerShell with the command

    %SystemRoot%\SysWOW64\WindowsPowerShell\v1.0\powershell .exe

2. In PowerShell run

    Install-Module MSAL.ps