Script repository

Send mail to parent container owner

Updated on: Jan 18, 2026, Views: 5407

Miscellaneous

The script sends an email notification to the owner of the container where the target object is located. To execute the script, create a business rule, custom command or scheduled task configured for the required object type.

Parameters

  • $subject - the email notification subject.
  • $message - the email notification text.
$subject = "My Subject" # TOOD: modify me
$message = @"
Message Text
"@ # TODO: modify me

# Bind to parent container.
$parent = $Context.BindToObject($Context.TargetObject.Parent)

# Get the container owner.
try
{
    $managerDN = $parent.Get("managedBy")
}
catch
{
    $Context.LogMessage("No owner is specified for container %adm-ParentName%", "Warning")
    return
}

# Get the owner email.
$manager = $Context.BindToObjectByDN($managerDN)
try
{
    $managerMail = $manager.Get("mail")
}
catch
{
    $Context.LogMessage("No email address is specified for the owner of container %adm-ParentName%", "Warning")
    return
}

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

Comments 0

You must be signed in to comment.

    Got questions?

    Support Questions & Answers

    We use cookies to improve your experience.
    By your continued use of this site you accept such use.
    For more details please see our privacy policy and cookies policy.