Jump to content

Focus Studio sending e-mails via EDAMAIL


Greg Weinheimer

Recommended Posts

Introduction
One thing that is not easy to do from Mainframe FOCUS which is now much easier to do with FOCUS Studio is creating a report and attaching and mailing that report as an attachment to an email.

This article will consist of two parts. Configuring the FOCUS Studio environment to set up the ability to send an email,  and then an example of a report that will be attached to an e-mail and sent after a successful execution of the report code.

Configuration
To configure the use of an e-mail server for use with the FOCUS Studio server, use the following steps.

From the main page from the FOCUS Studio Web Interface select Tools in the upper right hand corner and select Workspace.
 

email_pic1.png

From Workspace go to Settings/Workspace Set/SMTP Server Settings.
 

email_pic2.png

 

Fill out the SMTP setting with the appropriate values
SMTP Host - Is the valid e-mail server you will be sending e-mails through.
SMTP Port - Is the port the e-mail server uses(usually 25).
Sender e-mail - Is the default e-mail address that e-mails will be sent from for the FOCUS Studio server.

These are the only 3 values that are required.
 

email_pic3.png

 

Creating a report that sends the report as an attachment.

To return to the page,  left click on the ibi FOCUS Studio icon in the upper left hand corner.

email_pic5.png 

From the Applications screen right click the folder you want to create the e-mail report in, select new/procedure. This opens the FOCUS Studio editor.

email_pic6.png

 

Following is an example report with explanations of sections:

-* APP HOLD is used to tell the report where to hold any HOLD or SAVE files
APP HOLD DEMO1
-RUN
-* Simple report using CAR
TABLE FILE CAR
PRINT CAR COUNTRY
-* Holding the report format XLSX
ON TABLE HOLD AS CART FORMAT XLSX
END
-RUN
-TYPE &LINES
-* Using the &LINES internal FOCUS variable to check to see if a report was created
-IF &LINES GT 0 GOTO GOODRPT;
-IF &LINES LE 0 GOTO NORPT;
-* The GOTO if &LINES are greater than 0, i.e. a report was created.
-GOODRPT
-* The EDAMAIL syntax below will send an email to greg.xxxxx@cloud.com from 
-* gxxxx@tibco.com, with a subject of ‘GOOD REPORT’. ‘A’ denotes the following file should be
-* sent as an attachment. ‘XLSX’ denotes that the attachment is an excel file.
-* ‘demo1/cart’ denote the application folder and the name of the file to attach.
EX EDAMAIL greg.xxxxx@cloud.com,gxxxx@tibco.com,GOOD REPORT,A,XLSX,demo1/cart
-RUN
-* The GOTO NORPT will send an email if the report is empty or fails
-NORPT
-* 
EX EDAMAIL greg.xxxxx@cloud.com,gxxxx@tibco.com,REPORT FAILED
-RUN
 

email_pic8.png

Submitting the above report will attach the report to an e-mail and send it based on the parameters selected.

 

Below is an Appendix with the complete syntax for EDAMAIL.

Appendix:

Use EX EDAMAIL in the Extended Form
The EDAMAIL extended form using name-value pairs is activated by the detection of an equal sign (=) in the first parameter. Parameter names are not case-sensitive and may be in any order, but the message parameter (if used) must be last.
The syntax is:
EX EDAMAIL to=addresslist,
[toaddr= {addresslist|%[app/]addresslist.fex}, ]
[cc=cadrlist1,]      
[ccaddr=cadrlist2,]      
[bccaddr=bcadrlist,] [from=address,]
[fromaddr=address,] [replyto=address,] [importance=low|normal|high,]
[subject=string,] [flags=value,] [filetype=extension,]
[filename=file,] [message=body message]


where:
to=addresslist
Is the email recipient displayed by the user email client (and used in an email client Reply To All, if a toaddr header is not supplied). Multiple addresses are allowed, using a semi-colon (;) as the address separator. A comma (,) is also allowed as a separator, if the overall address string is enclosed in single quotation marks (').
If the to parameter is used in conjunction with toaddr, the value of to may be an arbitrary string, such as Group Managers, which most email clients will display as a pseudo title in the To field, and will not display the actual addresses used in the toaddr parameter. A forced blank can be supped for the To field by using to="".


toaddr=addresslist
Is the email recipient. If not supplied, SMTP servers will use the to header. Email clients will use the toaddr value in an email client Reply To All. Multiple addresses are allowed, using a semi-colon (;) as the address separator. A comma (,) is also allowed as a separator, if the overall address string is enclosed in single quotation marks (').

toaddr=%[app/]addresslist.fex
Is a FOCEXEC that generates an email recipient list at run time. Email clients will use the toaddr value in an email client Reply To All. The actual FOCEXEC may go against any data source for the addresses, but must PRINT a single column and use ON TABLE PCHOLD FORMAT COMT FORMATTED syntax to format the data (as one email address enclosed in double quotation marks (") per row).


The actual FOCEXEC extension must be .fex in the specification. This feature also only works in a running server context. It is not supported in any other mode.


cc=cadrlist1
Is the carbon copy recipient displayed by the user email client (and used in an email client Reply To All, if a ccaddr header is not supplied). Multiple addresses are allowed, using a semi-colon (;) as the address separator. A comma (,) is also allowed as a separator, if the overall address string is enclosed in single quotation marks (').


If the cc parameter is used in conjunction with ccaddr, the value of cc may be an arbitrary string, such as Group Managers, which most email clients will display as a pseudo title in the Cc field, without displaying the actual addresses used in the ccaddr parameter. A forced blank can be supped for the Cc field by using to="".


ccaddr=cadrlist2
Is the carbon copy recipient. If not supplied, SMTP servers will use the cc header. Email clients will use the ccaddr value in an email client Reply To All. Multiple addresses are allowed, using a semi-colon (;) as the address separator. A comma (,) is also allowed as a separator, if the overall address string is enclosed in single quotation marks (').


bccaddr=bcadrlist
Is the blind carbon copy recipient. Email clients will use the bccaddr value in an email client Reply To All. Multiple addresses are allowed, using a semi-colon (;) as the address separator. A comma (,) is also allowed as a separator, if the overall address string is enclosed in single quotation marks (').


from=address
Is the email sender displayed by the email client (and used in an email client Reply, unless overridden by a fromaddr or Reply To header). If the from parameter is used in conjunction with fromaddr, the from value may be an arbitrary string, such as The Boss, which most email clients will display as a pseudo title in the From field, and will not display the actual address used in the fromaddr parameter.


fromaddr=address
Is the email sender. If not supplied, most email clients will use the From header when doing a reply.


replyto=address
Is the email sender. If not supplied, most email clients will use the fromaddr or from parameter value.


importance=low|normal|high
Is the email importance level for email clients that support importance flags. Valid values are high, normal, and low.


subject=string
Is the email subject string. If the subject string contains a comma, the string must be enclosed in single or double quotation marks.


flags=value
If set to a or A, the file is sent as an attachment. Otherwise, it is included as the body of the email.


filetype=extension
Defines the data file type for an email message body that uses a file as the body. Any application file type is valid, including MASTER, FOCEXEC, HTML, TEXT, and so on. Leave the parameter out to use the inline email message body feature.


filename=file
Defines the data file for an email message body that uses a file as the body. Leave the parameter out to use the inline email message body feature.


message=body message
Is the inline data stream containing the email message body. If used, it must be the last parameter in the EDAMAIL command. To use the inline data stream feature, the filetype and filename parameters cannot be supplied. The data stream may also be spread onto multiple lines if EDAMAIL is used with the EX -LINES {n|*} feature.


If an inline data stream message body is spread across multiple lines in the procedure, the resulting email is a single line of output. Multi-line message bodies are respected when the message body from a file option is used.


Mailing an HTML File as a Message Body Using Multiple Addresses and Extended Form
TABLE FILE file1
PRINT A B C
ON TABLE HOLD AS MYFILE FORMAT HTML
END
EX EDAMAIL to=Managers,toaddr=user1@corp1.com;user2@corp1.com,
from=support1@corp1.com,subject=File1 Report, filetype=HTML, 
filename=MYFILE

  • Like 3
  • Thanks 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...