I recently wrote about using PowerShell to archive snapshots. One of the reasons I wanted to start using PowerShell instead of batch scripts was because PowerShell has the ability to send emails. As I was about to dig into how to write that code, a wonderful thing happened. Oracle released a new EPM Automate command to send email. This just made life a whole lot easier.
The EPM Automate command sendMail is straightforward and easy to understand. Per Oracle documentation:
epmautomate sendMail ToAddresse Subject [Body=”MessageBody”] [Attachments=FILE1,FILE2] where:
- ToAddresse identify semicolon separated email addresses of recipients. Example, email@example.com;firstname.lastname@example.org
- Subject identifies the email subject.
- Body=”MessageBody”, optionally, is the email content. If not specified, there is no body to the email.
- Attacments, optionally, identifies a comma separated list of files available in EPM Cloud to be attached to the email. For example, outbox/errorFile.txt,inbox/users.csv or outbox/use*.txt. In this example, the wildcard is applied only to one character in the string. Using outbox/use*.txt allows you to attach all files in the outbox with four letter file names that fit the pattern.
Using the PowerShell script we created for archiving snapshots, I added a line at the end to send an email.
Here’s the email that is received.
This is a very basic example. We can get more creative and send different emails depending on success or failure of the different steps in the script. But the beauty of using this EPM Automate command is that it’s so simple. There’s no need-to-know SMTP information and credentials, just enter one or more email addresses, a subject, and a message. You can also include attachments from the EPM Cloud inbox/outbox. One last note, this is a brand-new feature in EPM Automate that was introduced in the 20.04 cloud update. Be sure to download and install the latest version of EPM Automate to take advantage of new features each month.
As always, happy EPM’ng!