<?xml version="1.0" encoding="utf-8" ?>
<Configuration version="1.0">
<Feature Name="WelcomeEmail" Cmdlets="New-Mailbox,Enable-Mailbox">
<ApiCall Name="OnComplete">
if($succeeded) {
# Waiting for synchronization after mailbox has been created.
#Set-ADServerSettings -ViewEntireForest $true
Start-Sleep -s 1
$UsrAlias = $provisioningHandler.UserSpecifiedParameters["Alias"]
$UsrAddr = $USRalias + "@ff.local"
# Defining variables.
$UsrOU = (Get-Mailbox -Filter {Alias -eq $UsrAlias}).OrganizationalUnit
# Sending email notification to the user in specific OU.
if ($UsrOU -match "ff.local/Users") {
$UsrMsg = [string](Get-Content ("C:\WelcomeMessage\welcome.html"))
$UsrCC = "dd@ff.local"
$UsrSubject = "Добро пожаловать в компанию"
$UsrFrom = "pd@ff.local"
Send-MailMessage -SmtpServer smtp.ff.local -Port 3333 -Cc $UsrCC -To $UsrAddr -From $UsrFrom -Subject $UsrSubject -Body $UsrMsg -BodyAsHtml -Encoding ([System.Text.Encoding]::UTF8)
}
# Clearing variables. Each one in its own line in order to prevent error messages from being shown on EMC.
if ($UsrAlias) { Remove-Variable UsrAlias }
if ($UsrAddr) { Remove-Variable UsrAddr }
if ($UsrOU) { Remove-Variable UsrOU }
if ($UsrMsg) { Remove-Variable UsrMsg }
if ($UsrCC) { Remove-Variable UsrCC }
if ($UsrSubject) { Remove-Variable UsrSubject }
if ($UsrFrom) { Remove-Variable UsrFrom }
}
</ApiCall>
</Feature>
</Configuration>