Tips for handling email using Worksoft Certify

One of the key aspect of End-to-end Business Process validations is the Verify step. As part of verification steps, sometimes we have to send email notification to the concerned business users. Recently in one of our project we were supposed to send email to concerned team whenever the application server goes down. Although there is a separate MS office interface in Worksoft Certify to handle automation of MS Outlook to take care of all the basic functionalities of MS Outlook, such as sending/receiving emails, validations of email sent or received, etc. We achieved this using Certify and DOS Commands, as MS Outlook was not available on the client system. Find below the details of the solution and few other options.

Using Command Line SMTP:

Command Line SMTP is a Windows command line SMTP client, enabling quick and simple communication with a SMTP server from the command line. Command Line SMTP can be called directly from the command prompt. You can download Command Line SMTP from “www.commandlinesmtp.com”. In our solution, we created a batch file with the following commands.

CommandLineSMTP\CommandLineSMTP.exe/smtpserver:smtp.domain.com /to:receivermailid /from:sendermailid /subject:”subject line” /message:”content” /username:username /password:password /port:25
Optional parameters which can be used are:
/fromdisplayname (e.g. /fromdisplayname:”John Doe”)
/format (e.g. /format:text or /format:html) – Text is default.
/attachment (e.g. /attachment:”C:\Attachment.zip”) – Multiple attachments are supported.

Make sure that the batch file is placed in the same location as the CommandLineSMTP.exe. Based on the requirement of the Certify process call this batch file in the Certify step “execute application” from operating system object at the appropriate step. The mail will be sent successfully.

Find below few other options to send email.

Using Telnet SMTP commands:

Telnet is a protocol that allows you to connect to hosts over Internet. Using telnet client software on your computer, you can make a connection to a server.

Goto command prompt and type the following:
To open connection from your computer to the mail server type:
telnet mail.domain.ext 25 (Press enter)
MAIL FROM: mail@domain.ext (Press enter)
You will get a reply as Sender OK.
Now give the recipients address:
RCPT TO: mail@otherdomain.ext (Press enter)
You will get a reply as Receiver OK.
To start composing the message issue the command DATA
If you want a subject for your email type Subject: – type subject here- then press enter twice
You may now proceed to type the body of your message. To tell the mail server that you have completed the message enter a single “.” on a line on its own. The mail server should reply with:  Message accepted for delivery. You can close the connection by issuing the QUIT command.

Using POWERSHELL commands:

PowerShell is a task automation and configuration management framework from Microsoft, consisting of a command-line shell and associated scripting language built on the .NET Framework and .NET Core.

Below are the commands:

powershell
$EmailFrom = “your email id”
$EmailTo = “receiver email id”
$Subject = “The subject of your email”
$Body = “insert content here”
$SMTPServer = “smtp.domain.com”
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587)
$SMTPClient.EnableSsl = $true
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential(“username”, “password”);
Send-MailMessage -To $emailTo -From $emailFrom -Subject $Subject -Body $Body -SmtpServer $SmtpServer

Contribution by Divya Nayak

WRITTEN BY:

LEAVE A COMMENT