Hello Erlend,
The thing is that adding a member to a group means modifying the group, not the user, thus the %mail% value reference will be resolved into the e-mail of the group (if it has any), not the e-mail of the new member. To implement what you want, you need to send the e-mail message with the help of a script. For this purpose, add the Run a program or PowerShell script action to your Business Rule and paste the following script in the Script field:
$subject = "You have been added to Group %name%" # TODO: modify me
$bodyText = @"
Dear {0},
You have been added to group %name%.
Please do not reply to this e-mail, it has been sent to you for notification purposes only.
"@ # TODO: modify me
# Bind to the new member
$memberPath = @"
Adaxes://%member%
"@
$member = $Context.BindToObject($memberPath)
# Get email address of the new member
try
{
$mail = $member.Get("mail")
}
catch
{
return # No email address specified
}
# Insert the new member name in the e-mail body
$userFullName = $member.Get("name")
$body = [System.String]::Format($bodyText, $userFullName)
$Context.SendMail($mail, $subject, $body, $NULL)
In the script, modify the following to match your requirements:
- $subject - specifies the e-mail message subject,
- $bodyText - specifies a template for the e-mail message body. The {0} placeholder in the body will be replaced with the name of the new group member.