IScheduledTaskProperties.UseDynamicMailList

Syntax

UseDynamicMailList: Boolean;

Description

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

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 also be created in the repository, the unit implements the function to create the GetRecepients dynamical recipient list.

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 the recipients that will receive report about task failure
        //...
    Elseif Task.State = ScheduledTaskState.Succeeded Then
        //...
        //Add to Result the recipients that will receive report about successful task completion
        //...
    Else
        //...
        //Add to Result the recipients that will receive report in all other cases
        //...       
    End If;
    Return Result;
End Function GetRecepients;

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