IScheduledTaskProperties.UseDynamicMailList

Syntax

UseDynamicMailList: Boolean;

Description

The UseDynamicMailList property determines whether recipient list is created dynamically to send results of task completion.

Comments

Available values:

Example

Executing the example requires that the repository contains a scheduled tasks container with the TASK_CONTAINER identifier. Any task should be created in the container. A unit with the M_MAILLIST identifier should be also created in the repository, the unit implements the function to create the GetRecepients dynamical recipient list. The function has the following syntax:

GetRecepients syntax

Function GetRecepients(Task: IScheduledTask): IArrayList;
Var
    Mb: IMetabase;
    Result: IArrayList;
Begin
    Mb := Metabaseclass.Active;
    //Array for search of list of recipients
    Result := New ArrayList.Create;
    //Create a list according to task state
    If Task.State = ScheduledTaskState.Failed Then
        //...
        //Add to Result recipients that receive report about task execution failure
        //...
    Elseif Task.State = ScheduledTaskState.Succeeded Then
        //...
        //Add to Result recipients that receive report about successful task execution
        //...
    Else
        //...
        //Add to Result recipients that receive report in all other cases
        //...       
    End If;
    Return Result;
End Function GetRecepients;

rh-droptext_end ?>

Sub UserProc;
Var
    MB: IMetabase;
    Cont: IScheduledTasksContainer;
    Task: IScheduledTask;
    Props: IScheduledTaskProperties;
Begin
    MB := MetabaseClass.Active;
    Cont := MB.ItemById("TASK_CONTAINER").Bind As IScheduledTasksContainer;
    Task := Cont.Tasks.Item(0).Edit As IScheduledTask;
    Props := Task.Properties;
    //Dynamic list of recipients
    Props.SendMail := True;
    Props.UseDynamicMailList := True;
    Props.DynamicMailListModule := MB.ItemById("M_MAILLIST");
    Props.DynamicMailListMacro := "GetRecepients";
    Props.MailTargetType := ScheduledTaskMailTarget.Personal Or ScheduledTaskMailTarget.Work;
    (Task As IMetabaseObject).Save;
End Sub UserProc;

On executing the example parameters of task completion notification will be changed for the first task in the scheduled task container: recipient list will be created dynamically using the specified macro.

See also:

IScheduledTaskProperties