A
AirDuster101
Hi,
I am using outlook2003 and Exchange Server. I am trying to locate a calendar
name "*Education Calendar" in a public folder.
The path is "Public Folders\All Public Folders\EDUCATION\*Education
Calendar".
I've found the below script on Sue Mosher's site, but it can never find the
subfolder "EDUCATION". The object always returns "Nothing"... I don't know
why? Please help! I also tried in mixed case "Education". Same error.
Thanks
=============================================================
Dim objFolder As Outlook.MAPIFolder
Set objFolder = GetFolder("Public Folders/All Public
Folders/Education/*Education Calendar")
Public Function GetFolder(strFolderPath As String)As MAPIFolder
' folder path needs to be something like
' "Public Folders\All Public Folders\Company\Sales"
Dim objApp As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim colFolders As Outlook.Folders
Dim objFolder As Outlook.MAPIFolder
Dim arrFolders() As String
Dim I As Long
On Error Resume Next
strFolderPath = Replace(strFolderPath, "/", "\")
arrFolders() = Split(strFolderPath, "\")
Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
Set objFolder = objNS.Folders.Item(arrFolders(0))
If Not objFolder Is Nothing Then
For I = 1 To UBound(arrFolders)
Set colFolders = objFolder.Folders
Set objFolder = Nothing
Set objFolder = colFolders.Item(arrFolders(I))
If objFolder Is Nothing Then
Exit For
End If
Next
End If
Set GetFolder = objFolder
Set colFolders = Nothing
Set objNS = Nothing
Set objApp = Nothing
End Function
Isabelle
I am using outlook2003 and Exchange Server. I am trying to locate a calendar
name "*Education Calendar" in a public folder.
The path is "Public Folders\All Public Folders\EDUCATION\*Education
Calendar".
I've found the below script on Sue Mosher's site, but it can never find the
subfolder "EDUCATION". The object always returns "Nothing"... I don't know
why? Please help! I also tried in mixed case "Education". Same error.
Thanks
=============================================================
Dim objFolder As Outlook.MAPIFolder
Set objFolder = GetFolder("Public Folders/All Public
Folders/Education/*Education Calendar")
Public Function GetFolder(strFolderPath As String)As MAPIFolder
' folder path needs to be something like
' "Public Folders\All Public Folders\Company\Sales"
Dim objApp As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim colFolders As Outlook.Folders
Dim objFolder As Outlook.MAPIFolder
Dim arrFolders() As String
Dim I As Long
On Error Resume Next
strFolderPath = Replace(strFolderPath, "/", "\")
arrFolders() = Split(strFolderPath, "\")
Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
Set objFolder = objNS.Folders.Item(arrFolders(0))
If Not objFolder Is Nothing Then
For I = 1 To UBound(arrFolders)
Set colFolders = objFolder.Folders
Set objFolder = Nothing
Set objFolder = colFolders.Item(arrFolders(I))
If objFolder Is Nothing Then
Exit For
End If
Next
End If
Set GetFolder = objFolder
Set colFolders = Nothing
Set objNS = Nothing
Set objApp = Nothing
End Function
Isabelle