E-mail addresses

This code sample retrieves the following parameters of a mail-enabled contact:

  • E-mail addresses
  • Automatically update e-mail addresses based on e-mail address policy
  • External e-mail address

In the below code sample, the $contactParams variable represents Exchange properties of a mail-enabled contact. To retrieve the properties, use the IAdmExchangeMailParametersOps::GetMailParameters method.

 How
[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)

# Get Exchange properties
$contactParams = $contact.GetMailParameters()
# The $contactParams variable represents Exchange properties of a mail-enabled contact

# Email addresses
Write-Host "E-Mail addresses:"
$emailAddresses = $contactParams.EmailAddresses

for ($i = 0; $i -lt $emailAddresses.Count; $i++)
{
    $emailAddress = $emailAddresses.GetAddress($i,[ref]"ADS_PROPERTY_NONE")
    Write-Host "`t$emailAddress"
}

# External email address
Write-Host "External email address:" $contactParams.ExternalEmailAddress.Address

# Automatically update e-mail addresses based on e-mail address policy
Write-Host "Automatically update e-mail addresses based on e-mail address policy:" `
$contactParams.EmailAddressPolicyEnabled

See also