Well, that's no ordinary rabbit!
Note: See the MIS.OA.MSG.auto
page for an introduction to emailing from attributes and
reports.
Sending a scheduled report to a MOX mailbox is possible. If it is a
custom report is simply a matter of putting report data in your /
variable and calling the OA MSG program (example on MIS.OA.MSG.auto page) in
the report trailer or close up macro. For standard reports you need a
different approach.
Standard Meditech reports almost always have some kind of graphics commands in them. The email program simply sends these along with the text. Since the email program considers everthing as text the graphics commands need to be removed before sending the message.
The basic steps in the following method of emailing scheduled reports involves scheduling the report you want emailed to a unique spool group and creating a second scheduled report that does these things:
1. Identify the spool file to be sent.
2. Get the spool file from its hiding place (involves opening prefixes)
3. Remove graphics commands and copy the spool file to / file1
4. Reprocess / file1 to remove non-printing characters and save in / file2
5. Send / file2 using the MIS.OA.MSG.auto program
The code below should work for any magic site but I would appreciate any suggestions or improvements anyone has to offer.
Identify the spool file
The easiest way to identify the spool file is to use a unique spool group. If the report gets run once a day it is then as easy as creating a report that finds any spool file for the spool group for a certain date. The report should be in MIS.SPOOL and only needs to select on group and date.created. See the report specifics below.
Get the spool file
Once the report has identified the spool file urn the spool file needs to be retrieved from where Meditech has stored it (%.MIS.spool.rad). This involves opening prefixes so don't ask Meditech for any help on it.
Loop thru the spool file, strip the graphics commands and save in a / file
Get each line from the spool file, run it thru the standard Meditech program Z.rw.strip.graphics to remove any graphics commands, and save the result in / file1.
Reprocess the / file to join split lines and save in a second / file
Meditech splits the spool file into 80 character lines. If the report you want to email is wider that 80 characters lines will need to be concatonated in order to keep the correct output format. This code should work for reports up to 160 characters wide but will need to be modified if the report CPL is greater than that. Save the resulting line in / file2.
Determine the recipients
If the report is being used to email several spool files to different users the report title which is in the first line of the spool file can be used to determine who gets the email.
Send the file
%MIS.OA.MSG.auto("",ARG)X,1
This is for the second report, the one that finds and processes the spool file of the report you want emailed. It doesn't need any output, just some selects and a detail macro.
This macro strips
non printing characters from the string
;---
the
following must all be entered on one line.
;---
you can enter it as 2 and then use F6 to join the 2 lines
A'~(D(255):32_"
"_"!"_D(34)_"#$%&'"_D(40,41)_"*+,-./0123456789:;<=>?@ABCDEFGHI
JKLMNOPQRSTUVWXYZ[\]"_D(255,95,96)_"abcdefghijklmnopqrstuvwxyz{~}"_(D(255):2));
Don't see what you
need? Visit one of these other sites
or email me your request (tomt at thomast357.com).