Sub GetAddressMap()
Dim myResults As New StringBuilder
Dim oAddressMap As New MailEnable.Administration.AddressMap
oAddressMap.Account = "Test"
If (oAddressMap.FindFirstAddressMap() = 1) Then
Do
myResults.AppendLine("Scope: " & oAddressMap.Scope)
myResults.AppendLine("Account: " & oAddressMap.Account)
myResults.AppendLine("DestinationAddress: " & oAddressMap.DestinationAddress)
myResults.AppendLine("SourceAddress: " & oAddressMap.SourceAddress)
Loop While (oAddressMap.FindNextAddressMap() = 1)
End If
results.Text = myResults.ToString()
oAddressMap = Nothing
End Sub
I have the same behavior with the Domain class. No idea what is going wrong.
I worked like this. What I understand from it is that the FindFirst... set the loop on the first position of the filter specified in oDomain and then the FindNext, continues on this filter. What was confusing is that you need to set the filter once again before the FindNext. Also it is unclear what values the oDomain (oAddressMap, ...) require to be able to work in the loop. I used this based on combining documentation and examples.
Sub GetDomains(ByVal sPostOffice As String)
Dim myResults As New StringBuilder
Dim oDomain As New MailEnable.Administration.Domain
With oDomain
.DomainName = ""
.AccountName = sPostOffice
.Status = -1
.DomainRedirectionStatus = -1
.DomainRedirectionHosts = ""
End With
If (oDomain.FindFirstDomain = 1) Then
Do
myResults.AppendLine("DomainName: " & oDomain.DomainName)
myResults.AppendLine("AccountName: " & oDomain.AccountName)
myResults.AppendLine("Status: " & oDomain.Status)
myResults.AppendLine("DomainRedirectionStatus: " & oDomain.DomainRedirectionStatus)
myResults.AppendLine("DomainRedirectionHosts: " & oDomain.DomainRedirectionHosts)
With oDomain
.DomainName = ""
.AccountName = sPostOffice
.Status = -1
.DomainRedirectionStatus = -1
.DomainRedirectionHosts = ""
End With
Loop While oDomain.FindNextDomain = 1
End If
results.Text = myResults.ToString()
oDomain = Nothing
End Sub