Hello guys,
I have hit a dead end in trying to solve this problem. The thing is, I can't run the the program here because it has to run on a server which is in another place. All I receive here is a logfile with exceptions that happens when they test the program on the server.
I'm using VS2005, VB.NET, XP Pro, CDO 1.21 dll
Anyway, this function Logs on and traverses through "Public Folders" until it finds a folder I'm looking for.
I hope someone could help me cause I need to resolve this fast.
Here is the source code:
and this is the code for the GetFolderByName Function
Please help,
JAN
I have hit a dead end in trying to solve this problem. The thing is, I can't run the the program here because it has to run on a server which is in another place. All I receive here is a logfile with exceptions that happens when they test the program on the server.
I'm using VS2005, VB.NET, XP Pro, CDO 1.21 dll
Anyway, this function Logs on and traverses through "Public Folders" until it finds a folder I'm looking for.
I hope someone could help me cause I need to resolve this fast.
Here is the source code:
Code:
Public Sub Logon(ByVal profile As String, ByVal RootFolder As String)
m_Session = New MAPI.Session
m_Session.Logon(profile, , False, , , , )
' Go the fax store
Dim Folders As String() = RootFolder.Split("/".ToCharArray())
Dim i As Integer
Dim objInfoStores As Object
Dim objPublicFolderRoot As Object
Dim objParent As Object
Dim Parent As MAPI.Folder
objInfoStores = m_Session.InfoStores
m_InfoStores = DirectCast(objInfoStores, MAPI.InfoStores)
For i = 1 To CInt(m_InfoStores.Count)
Dim InfoStoreName As String
objPublicFolderRoot = m_InfoStores.Item(i)
InfoStoreName = m_InfoStores.Item(i).ToString
If InfoStoreName = Folders(0) Then
m_PublicFolderRoot = DirectCast(objPublicFolderRoot, MAPI.InfoStore)
Exit For
End If
Next
objParent = m_PublicFolderRoot.RootFolder
Parent = DirectCast(objParent, MAPI.Folder)
For i = 1 To Folders.Length - 1
Parent = GetFolderByName(Folders(i), Parent)
Next
m_FaxRoot = Parent
End Sub
Code:
Friend Function GetFolderByName(ByVal folderName As String, Optional ByVal parent As MAPI.Folder = Nothing) As MAPI.Folder
Dim CdoSession As MAPI.Session = m_Session
Dim CdoInfoStores As MAPI.InfoStores
Dim CdoInfoStore As MAPI.InfoStore
Dim CdoFolderRoot As MAPI.Folder
Dim CdoFolders As MAPI.Folders
Dim CdoFolder As MAPI.Folder
Dim bFound As Boolean
Dim i As Integer = 1
Dim objInfoStores As Object
Dim objInfoStore As Object
Dim objFolderRoot As Object
Dim objFolders As Object
Dim objParentFolders As Object
Dim objFolder As Object
If parent Is Nothing Then
objInfoStores = CdoSession.InfoStores
CdoInfoStores = DirectCast(objInfoStores, MAPI.InfoStores)
objInfoStore = CdoInfoStores.Item("Public Folders")
CdoInfoStore = DirectCast(objInfoStore, MAPI.InfoStore)
For i = 1 To CInt(CdoInfoStores.Count)
Dim InfoStoreName As String
objInfoStore = CdoInfoStores.Item(i)
InfoStoreName = CdoInfoStores.Item(i).ToString
If InfoStoreName = "Public Folders" Then
CdoInfoStore = DirectCast(objInfoStore, MAPI.InfoStore)
Exit For
End If
Next
objFolderRoot = CdoInfoStore.RootFolder
CdoFolderRoot = DirectCast(objFolderRoot, MAPI.Folder)
objFolders = CdoFolderRoot.Folders
CdoFolders = DirectCast(objFolders, MAPI.Folders)
Else
' Get the Folders collection from the parent folder.
objParentFolders = parent.Folders
CdoFolders = DirectCast(objParentFolders, MAPI.Folders)
End If
' Loop through the folders in the collection until the
' desired folder is found.
bFound = False
objFolder = CdoFolders.GetFirst
CdoFolder = DirectCast(objFolder, MAPI.Folder)
Do While (Not bFound) And Not (CdoFolder Is Nothing)
If CdoFolder.Name.ToString = folderName Then
bFound = True
Else
objFolder = CdoFolders.GetNext
CdoFolder = DirectCast(objFolder, MAPI.Folder)
End If
Loop
GetFolderByName = CdoFolder
' Release our local objects.
CdoFolder = Nothing
CdoFolders = Nothing
CdoFolderRoot = Nothing
CdoInfoStore = Nothing
CdoInfoStores = Nothing
End Function ' GetFolderByName
JAN
Comment