Mail Flow
Modify message size restrictions
[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 contact
$contactDN = "CN=My Contact,CN=Contacts,DC=domain,DC=com"
$contact = $service.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
$ns = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$service = $ns.GetServiceDirectly("localhost")
# Bind to the contact
$contactDN = "CN=My Contact,CN=Contacts,DC=domain,DC=com"
$contact = $service.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
$ns = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$service = $ns.GetServiceDirectly("localhost")
# Bind to the contact
$contactDN = "CN=My Contact,CN=Contacts,DC=domain,DC=com"
$contact = $service.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
$ns = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$service = $ns.GetServiceDirectly("localhost")
# Bind to the contact
$contactDN = "CN=My Contact,CN=Contacts,DC=domain,DC=com"
$contact = $service.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
$ns = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$service = $ns.GetServiceDirectly("localhost")
# Bind to the contact
$contactDN = "CN=My Contact,CN=Contacts,DC=domain,DC=com"
$contact = $service.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
- Performing Exchange tasks
- Writing ADSI scripts
- Server-side scripting
- IAdmExchangeMailParametersOps
- IAdmExchangeMailParameters
- IAdmExchangeMailContactParameters
- IAdmExchangeMailFlowSettings
- Online script repository