-
Outlook Folder Path
Goo day all
I have this problem pointing the correct outlook subfolder path, it gives me "run time error 13".
The sub folder is "CHHIEW\Hong\Report", it's outside of inbox folder, have tried many times changing the "/" and "" but still did'nt work, anyone got any idea how to fix this?
Thank you for your help
Code:
Private Sub Application_Startup()
Dim olNs As Outlook.NameSpace
Dim Inbox As Outlook.MAPIFolder
Dim olFolder As Outlook.MAPIFolder
Dim GetFolder As Outlook.MAPIFolder
Dim objFolder As Outlook.MAPIFolder
Set olNs = Application.GetNamespace("MAPI")
Set Inbox = olNs.GetDefaultFolder("\\CHHIEW\Hong\Report")
Set Items = Inbox.Items
End Sub
-
I don't think it is possible to set the inbox in this way, however to get the folder, you would need code like the following. The message boxes are purely for testing.
Code:
Sub Test()
Dim olNS As NameSpace
Dim olStore As Store
Dim olItem
Dim olFolder As Folder
Dim bFound As Boolean
Set olNS = Application.GetNamespace("MAPI")
For Each olStore In olNS.Stores
If olStore.DisplayName = "CHHIEW" Then
bFound = True
Exit For
End If
Next olStore
If Not bFound Then
MsgBox "The store CHHIEW was not found"
GoTo lbl_Exit
End If
Set olFolder = olStore.GetRootFolder.folders("Hong").folders("Report")
MsgBox olFolder.FolderPath
lbl_Exit:
Exit Sub
End Sub
-
Hi Gmayor,
Thanks for your help. yes i can see the msgbox displayed the folder path, but how can i incorporate that path in my script?
sorry i am newbie with limited programming knowledge to outlook vba.
Thanks
-
The message box is there to show that the code works. olFolder is the folder related to that path.
-
Gmayor,
Thank you so much. will explore and figure out this.
Thanks