Skip to content

Mail Flow

Modify message size restrictions

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

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

# Bind to the contact
$contactDN = "CN=My Contact,CN=Users,DC=domain,DC=com"
$contact = $admService.OpenObject("Adaxes://$contactDN", $NULL, $NULL, 0)

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

$messageSizeRestrictions = $contactParams.MailFlowSettings.MessageSizeRestrictions
$messageSizeRestrictions.IsModificationEnabled = $True

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

$messageSizeRestrictions.MaxReceiveSize = $maxReceiveSize

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

# Set maximum mesage size
$messageSizeRestrictions.MaxSendSize = $maxSendSize
$contact.SetMailParameters($contactParams, "ADM_SET_EXCHANGE_PARAMS_FLAGS_RESOLVEVALUEREFERENCES")

Modify message delivery restrictions

The following code sample configures a mail-enabled contact to accept messages only from senders inside their organization.

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

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

# Bind to the contact
$contactDN = "CN=My Contact,CN=Users,DC=domain,DC=com"
$contact = $admService.OpenObject("Adaxes://$contactDN", $NULL, $NULL, 0)

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

$messageDeliveryRestrictions = $contactParams.MailFlowSettings.MessageDeliveryRestrictions
$messageDeliveryRestrictions.IsModificationEnabled = $True

$messageDeliveryRestrictions.RequireSenderAuthentication = $True
$messageDeliveryRestrictions.AcceptMessagesOnlyFrom.OverrideOldValues = $True
$messageDeliveryRestrictions.AcceptMessagesOnlyFromModificationEnabled = $True

# Save changes
$contact.SetMailParameters($contactParams, "ADM_SET_EXCHANGE_PARAMS_FLAGS_RESOLVEVALUEREFERENCES")

The following code sample configures a mail-enabled contact to accept messages from all senders.

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

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

# Bind to the contact
$contactDN = "CN=My Contact,CN=Users,DC=domain,DC=com"
$contact = $admService.OpenObject("Adaxes://$contactDN", $NULL, $NULL, 0)

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

$messageDeliveryRestrictions = $contactParams.MailFlowSettings.MessageDeliveryRestrictions
$messageDeliveryRestrictions.IsModificationEnabled = $True

$messageDeliveryRestrictions.RequireSenderAuthentication = $False
$messageDeliveryRestrictions.AcceptMessagesOnlyFrom.OverrideOldValues = $True
$messageDeliveryRestrictions.AcceptMessagesOnlyFromModificationEnabled = $True

# Save changes
$contact.SetMailParameters($contactParams, "ADM_SET_EXCHANGE_PARAMS_FLAGS_RESOLVEVALUEREFERENCES")

The following code sample configures a mail-enabled contact to accept messages only from a specific user.

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

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

# Bind to the contact
$contactDN = "CN=My Contact,CN=Users,DC=domain,DC=com"
$contact = $admService.OpenObject("Adaxes://$contactDN", $NULL, $NULL, 0)

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

$messageDeliveryRestrictions = $contactParams.MailFlowSettings.MessageDeliveryRestrictions
$messageDeliveryRestrictions.IsModificationEnabled = $True

$userDN = "CN=John Smith,CN=Users,DC=example,DC=com"

$objReference = New-Object "Softerra.Adaxes.Adsi.AdmObjectReference"
$objReference.ObjectDN = $userDN

$acceptMessagesOnlyFrom = $messageDeliveryRestrictions.AcceptMessagesOnlyFrom
$acceptMessagesOnlyFrom.OverrideOldValues = $False
$acceptMessagesOnlyFrom.Add("ADS_PROPERTY_APPEND", $objReference)

$messageDeliveryRestrictions.AcceptMessagesOnlyFrom = $acceptMessagesOnlyFrom

# Save changes
$contact.SetMailParameters($contactParams, "ADM_SET_EXCHANGE_PARAMS_FLAGS_RESOLVEVALUEREFERENCES")

The following code sample configures a mail-enabled contact to reject messages from a specific user.

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

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

# Bind to the contact
$contactDN = "CN=My Contact,CN=Users,DC=domain,DC=com"
$contact = $admService.OpenObject("Adaxes://$contactDN", $NULL, $NULL, 0)

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

$messageDeliveryRestrictions = $contactParams.MailFlowSettings.MessageDeliveryRestrictions
$messageDeliveryRestrictions.IsModificationEnabled = $True

$userDN = "CN=John Smith,CN=Users,DC=example,DC=com"

$objReference = New-Object "Softerra.Adaxes.Adsi.AdmObjectReference"
$objReference.ObjectDN = $userDN

$rejectMessagesFrom = $messageDeliveryRestrictions.RejectMessagesFrom
$rejectMessagesFrom.OverrideOldValues = $False
$rejectMessagesFrom.Add("ADS_PROPERTY_APPEND", $objReference)

$messageDeliveryRestrictions.RejectMessagesFrom = $rejectMessagesFrom

# Save changes
$contact.SetMailParameters($contactParams, "ADM_SET_EXCHANGE_PARAMS_FLAGS_RESOLVEVALUEREFERENCES")

See also