Script Repository


Send multi-value property values via email

February 24, 2021
446

The script sends an email notification containing all values of a multi-value property. To run the script, you can use a custom command, a business rule or a scheduled task configured for the corresponding object type (e.g. user).

Parameters:

  • $propertyName - Specifies the LDAP name of the property whose values will be included into the email notification.
  • $to - Specifies the recipient's email address.
  • $subject - Specifies the email notification subject.
  • $messageTemplate - Specifies a template of the email notification. In the template, the {0} placeholder will be replaced with values of the property spacified in the $propertyName variable.
Edit Remove
PowerShell
$propertyName = "adm-CustomAttributeTextMultiValue1" # TODO: modify me

# E-mail settings
$to = "recipeint@domain.com" # TODO: modify me
$subject = "Values of '$propertyName' property" # TODO: modify me
$messageTemplate = "Values: {0}" # TODO: modify me

# Get property values
try
{
    $values = $Context.TargetObject.GetEx($propertyName)
}
catch
{
    $values = $NULL
}

if ($values -eq $NULL)
{
    $values = "Not specified"
}
else
{
    $values = [System.String]::Join(";", $values)
}

# Build message
$message = [System.String]::Format($messageTemplate, $values)

# Send mail
$Context.SendMail($to, $subject, $message, $NULL)


Comments ( 0 )
No results found.
Leave a comment

Related Scripts