Knowledge Base

Welcome to The Carlisle Group's Knowledge Base.

Search or Ask a Question

This is a keyword search that looks for matching articles that contain one or more words specifically by a user in articles’ tags, title and content. Admin writes brief intro content here via admin end. If you are unable to find an answer to your issue, please submit an issue here.

Back to Articles List

Sample Script - Email a report in the message body. | CAS 6.0

Added: 07/26/2016; Last Modified: 07/26/2016; Visits:699

This sample script will email a HTML report in the body of a message.

 

⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝
⍝⍝ Description = Email a CAS report as HTML
⍝⍝
⍝⍝ Written By  = The Carlisle Group.
⍝⍝ CAS         = 6.0
⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝

⍝ Get the current CAS file.
 CS←CasSession.GetCurrentFile''

⍝ Set a temporary report file path.
 TempFilePath←CharString.New'c:\temp\rep.html'

⍝ Get the CAS report item.
 OB←CS.GetItem'\CAS Items\Table Report\Main Sample'

⍝ Run the report to HTML
 R←CS.RunCASReport OB'HTML' 0

⍝ Save the HTML to a temporary file.
 R.SaveAs TempFilePath

⍝ Read the report file and convert to a single string.
 TF←TextFile.New TempFilePath
 SL←TF.Read2''
 HTML←SL.ToString''

⍝ Setup a new Mail object
 M←Mail.New''
 M.Subject←'Hi there'
 M.AddTo'some@email.com'
 M.Body←HTML

⍝ It's important to set the HTML flag to 1.
⍝ If not, the data won't be formatted properly.
 M.IsHTML←1

⍝ Initiate the send.
 M.Send''