Mail Flow

The following code sample modifies message size restrictions for a mail-enabled group.

[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")

# Connect to the Adaxes service
$ns = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$service = $ns.GetServiceDirectly("localhost")

# Bind to the group
$groupDN = "CN=MyGroup,CN=Users,DC=example,DC=com"
$group = $service.OpenObject("Adaxes://$groupDN", $null, $null, 0)

# Create an instance of the AdmExchangeMailGroupParameters class
$groupParams = New-Object "Softerra.Adaxes.Adsi.Exchange.AdmExchangeMailGroupParameters"

$messageSizeRestrictions = $groupParams.MailFlowSettings.MessageSizeRestrictions
$messageSizeRestrictions.IsModificationEnabled = $true

# Set maximum receiving message size to 25 MB
$maxReceiveSize = New-Object "Softerra.Adaxes.Adsi.Exchange.AdmByteQuantifiedSize"
$maxReceiveSize.SetMBytes(25)

$messageSizeRestrictions.MaxReceiveSize = $maxReceiveSize

# Set maximum sending message size to 25 MB
$maxSendSize = New-Object "Softerra.Adaxes.Adsi.Exchange.AdmByteQuantifiedSize"
$maxSendSize.SetMBytes(25)

$messageSizeRestrictions.MaxSendSize = $maxSendSize

# Save changes
$group.SetMailParameters($groupParams, "ADM_SET_EXCHANGE_PARAMS_FLAGS_NONE")

See also