Loop AddressMap

Discussion for developers using MailEnable.
Post Reply
WimVM
Posts: 28
Joined: Fri May 25, 2007 9:56 am

Loop AddressMap

Post by WimVM »

Hello,

I want to list all addressmaps for my server. I tried it for the Postoffice "Test", but when I try the code below it only lists the first one.

Code: Select all

    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.

Thanks

WimVM
Posts: 28
Joined: Fri May 25, 2007 9:56 am

Re: Loop AddressMap

Post by WimVM »

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.

Code: Select all

    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

Post Reply