Intimatik
  • Intimatik
  • 53.75% (Neutral)
  • Newbie Topic Starter
14 years ago
I've got 1000+ imap folders . Everytime i search for a folder i'm making a new loop to find in collection of folders by name. It takes much time.

Is there any possibility to make it faster?
ivan
  • ivan
  • 100% (Exalted)
  • Administration
14 years ago

I've got 1000+ imap folders . Everytime i search for a folder i'm making a new loop to find in collection of folders by name. It takes much time.

Is there any possibility to make it faster?

Intimatik wrote:



You can use this method to select the imap4 folder directly.

VB6

Dim oFolder As New Imap4Folder
oFolder.ServerPath = "Deleted Items"
oFolder.FullPath = "Deleted Items"

oClient.SelectFolder  oFolder 

The problem problem is: you must know the folder server path.
I suggest that you use loop to get all folders server path at first, then you can use server path to select the folder directly.

VB6

Public Sub ConnectImapServer(ByVal Server As String, _
ByVal User As String, _
ByVal Password As String, _
ByVal SSLConnection As Boolean)

Const MailServerPop3 = 0
Const MailServerImap4 = 1

On Error GoTo ErrorHandle
    Dim oServer As New EAGetMailObjLib.MailServer
    oServer.Server = Server
    oServer.User = User
    oServer.Password = Password
    oServer.SSLConnection = SSLConnection
    oServer.Protocol = MailServerImap4
    If oServer.SSLConnection = True Then
        oServer.Port = 993
    Else
        oServer.Port = 143
    End If
    
    Dim oClient As New EAGetMailObjLib.MailClient
    oClient.LicenseCode = "TryIt"
    
    oClient.Connect oServer
    
    Dim arFolder
    arFolder = oClient.Imap4Folders
     'enumerates all folders on IMAP4 server.
    EnumerateFolder arFolder
    oClient.Logout
    
    Exit Sub
ErrorHandle:
    MsgBox Err.Description
End Sub

Public Sub EnumerateFolder(oFolders)
    Dim i, count As Integer
    count = UBound(oFolders)
    For i = LBound(oFolders) To count
        Dim oFolder As EAGetMailObjLib.Imap4Folder
        Set oFolder = oFolders(i)
        Dim s

' You can get the FullPath and ServerPath like this, then you can
' save it to a configuration file, next time you can use FullPath and ServerPath
' to access this folder directly

        s = "Name: " & oFolder.Name & Chr(13) & Chr(10)
        s = s & "FullPath: " & oFolder.FullPath & Chr(13) & Chr(10)
        s = s & "ServerPath: " & oFolder.ServerPath & Chr(13) & Chr(10)
        MsgBox s
        EnumerateFolder oFolder.SubFolders
    Next   
End Sub
Intimatik
  • Intimatik
  • 53.75% (Neutral)
  • Newbie Topic Starter
14 years ago
It works! Thanks!
ditte
  • ditte
  • 61.25% (Friendly)
  • Member
14 years ago
How is the syntax, if the folder has subfolder and I want use one of this?


Dim oFolder As New Imap4Folder
oFolder.ServerPath = "INBOX/Fax-Journal"
oFolder.FullPath = "INBOX/Fax-Journal"

oClient.SelectFolder oFolder

ditte
  • ditte
  • 61.25% (Friendly)
  • Member
14 years ago
found it.

Dim oFolder As New Imap4Folder
oFolder.ServerPath = "INBOX.Fax-Journal"
oFolder.FullPath = "INBOX.Fax-Journal"

oClient.SelectFolder oFolder

EXPLORE TUTORIALS

© All Rights Reserved, AIFEI Software Limited & AdminSystem Software Limited.