Skip to content

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

Note

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
$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)

# 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