CreateEmailJob()
Requires CAPITAL Electronic Document Exchange Component
Places an Email job request directly into the Visual Builder print job queue.
Syntax
CreateEmailJob(<cForm>, <cTo>, <cSubject>, [<cMsg>], [<cAttach>], [<cCC>], [<cBCC>], [<cScript>], [<cSpool>], [<nPriority]>, [lFax]) --> lResult
Arguments
<cForm> --> is the name of the Visual Builder form to create a PDF attachment of. Do not specify the path or the form's file extension.
<cTo> --> the destination Email address.
<cSubject> --> the subject heading of the Email address.
<cMsg> --> is the optional message body.
<cAttach> --> is the name of an optional additional attachment file.
<cCC> --> is the optional carbon copy address.
<cBCC> --> is the optional blind carbon copy address.
<cScript> --> is an optional character string containing a script that Visual Builder will execute before it executes the form.
<cSpool> --> optionally specify the spooler to insert the job into. If not specified, the job request is inserted into the default spool file.
<nPriority> --> optionally specifies the job's print priority. The range is 1-4, with the highest = 1, and the lowest (normal) = 4. The default is 4.
Print
jobs with a priority of 1 are sent immediately, regardless of scheduler settings.
<lFax> --> If TRUE is passed the email job is formatted as a fax for transmission through an SMTP email to fax gateway. For more information on CAPITAL's fax capabilities see the topic Faxing in the main CAPITAL on-line help reference.
Returns
If the Email job was successfully entered in the print queue, TRUE is returned. Otherwise FALSE.
Description
This is a special purpose function that allows a report to scan a database and selectively indicate which records are to be emailed and which Visual Builder form is to be used as the PDF attachment. For example, it is possible to create a report that scans the Customer database and selectively emails invoices or statements.
In order for the above to function usefully, there must be a relationship between the report that creates the EMail job requests and the form that results in the creation of the PDF attachment.
Using the Service Manager as an example, the standard Service Manager Job Card form checks for the variable FirstTran in the Preface section of the form. The contents of this variable instructs the form on what job card to 'print.'
By creating a script that assigns this variable a value, the JOBCARD.STY form can be instructed to 'print' the job records indicated by the report that executes the CreateEmailJob() function. The general procedure is:
1. Create a report that scans a selected database.
2. If custom conditions are met, the CreateEmailJob() function is executed.
3. This report does not print to paper, outputs its contents to "none". (There is no particular reason to print this report unless you want a list of the records that will generate EMails and their PDF attachments.)
4. Ensure that the CreateEmailJob() function passes a script to the form, so that the form can use it to determine which records to generate PDF's for.
5. When the report finishes processing, new jobs will be placed in the Visual Builder print queue. Visual Builder will start emailing these queued jobs, based on CAPITAL's Electronic Document Exchange component settings.
For more information on creating scripts, see the function: CreatePrintJob().
____________________________
Related Topics: