Data Integration Blog

Dev Hack: Email On-the-Fly

Send Email From Anywhere with Dynamically Set Fields and Attachments with or without Macros

by David Byrd, Senior Integration Consultant, QuickArrow

In our shop we wanted to use common code to detect error handling and message notification. One of the key things we wanted to be able to control is “Who” receives messages and the “Subject” of those messages. We especially needed to be able to specify which of our roughly 300 client companies the email relates to. Specifying a subject dynamically is fairly difficult using the Email Invoker step in the Pervasive Process Designer without using macros ( not all our jobs have macrodef.xml files). However, using component code in RIFL, a hard value, a macro value, or a variable or any combination of those three can be set, as shown below in the From, To, and Subject fields:

The cool thing here is that this email component code can actually be fired from inside a map, allowing the map to not only transform data as it traditionally does, but potentially email different people on-the-fly using an email address derived from the source. In fact, with this bit of code, emails are not limited to a process level invoker step, but can be sent from virtually any location that allows RIFL code.

If you need an attachment, the code is a bit more complicated, but follows the same basic principles.

Email With an Attachment Code

In this example, the path and file name for the CustomBacklogReport.xls is hard-coded on line 8, but it could just as easily be a macro value, variable, or string with an embedded variable like the subject line in the previous example. We needed timestamp information added to this one, so, as you can see, even the result of a function like Now() can show up in the Subject line of an email using this method.

Being able to send email from any point in an integration design, with fields set to hard coded, variable, macro values, or even function results, and attachments added that point to hard, variable, or macro value file paths, greatly increases the versatility of the email capability of the Pervasive tools.

Comments

computer file recovery said:

When a virus deletes part of a file or a user unintentionally deletes a file or an entire folder from user access, the data does not immediately disappear forever.

July 10, 2009 9:39 PM