K
Kam
Hi everyone,
I am trying to read mails which stores in a folder under "Public folders" on our server. I can walk through the folders but I don't know how to get the messages. I have inclosed my code, i hope it does help.
Looking forward to hearing from you soon.
Kam
================================================================
Dim ColMapiFolder As Outlook.Folders
Dim Mapifolder As Outlook.Mapifolder
Dim ColFolders As Outlook.Folders
Dim Folders As Outlook.Mapifolder
Dim ColMapiFolders2 As Outlook.Folders
Dim Mapifolder2 As Outlook.Mapifolder
Dim ColMapiFolders3 As Outlook.Folders
Dim MapiFolder3 As Outlook.Mapifolder
Dim ColMapiFolders4 As Outlook.Folders
Dim MapiFolder4 As Outlook.Mapifolder
Dim ColMapiFolders5 As Outlook.Folders
Dim MapiFolder5 As Outlook.Mapifolder
Dim ColMapiFolders6 As Outlook.Folders
Dim MapiFolder6 As Outlook.Mapifolder
Dim Treenode As Node
Set olApp = New Outlook.Application
Set olNS = olApp.GetNamespace("Mapi")
Set MySession = CreateObject("MAPI.Session")
Set ColMapiFolder = olNS.Folders
For Each Mapifolder In ColMapiFolder
If Mapifolder.Name = "Public Folders" Then
Set ColMapiFolders2 = Mapifolder.Folders
For Each Mapifolder2 In ColMapiFolders2
If Mapifolder2.Name = "YYY YYYYYY folders" Then
Set ColMapiFolders3 = Mapifolder2.Folders
For Each MapiFolder3 In ColMapiFolders3
If MapiFolder3.Name = "XXX QXXXXXX SXXXXX" Then
Set ColMapiFolders4 = MapiFolder3.Folders
For Each MapiFolder4 In ColMapiFolders4
If MapiFolder4.Name = "Accepted" Then
With tvMail.Nodes
Set Treenode = .Add(, , "root", MapiFolder4.Name, 1)
End With
Set ColMapiFolders5 = MapiFolder4.Folders
For Each MapiFolder5 In ColMapiFolders5
With tvMail.Nodes
Set Treenode = .Add("root", tvwChild, , MapiFolder5.Name, 1)
End With
Next
End If
Next
End If
Next
End If
Next
End If
Next
Set ColMapiFolders4 = Nothing
Set ColMapiFolders3 = Nothing
Set ColMapiFolders2 = Nothing
Set ColMapiFolder = Nothing
Set MySession = Nothing
Set olNS = Nothing
I am trying to read mails which stores in a folder under "Public folders" on our server. I can walk through the folders but I don't know how to get the messages. I have inclosed my code, i hope it does help.
Looking forward to hearing from you soon.
Kam
================================================================
Dim ColMapiFolder As Outlook.Folders
Dim Mapifolder As Outlook.Mapifolder
Dim ColFolders As Outlook.Folders
Dim Folders As Outlook.Mapifolder
Dim ColMapiFolders2 As Outlook.Folders
Dim Mapifolder2 As Outlook.Mapifolder
Dim ColMapiFolders3 As Outlook.Folders
Dim MapiFolder3 As Outlook.Mapifolder
Dim ColMapiFolders4 As Outlook.Folders
Dim MapiFolder4 As Outlook.Mapifolder
Dim ColMapiFolders5 As Outlook.Folders
Dim MapiFolder5 As Outlook.Mapifolder
Dim ColMapiFolders6 As Outlook.Folders
Dim MapiFolder6 As Outlook.Mapifolder
Dim Treenode As Node
Set olApp = New Outlook.Application
Set olNS = olApp.GetNamespace("Mapi")
Set MySession = CreateObject("MAPI.Session")
Set ColMapiFolder = olNS.Folders
For Each Mapifolder In ColMapiFolder
If Mapifolder.Name = "Public Folders" Then
Set ColMapiFolders2 = Mapifolder.Folders
For Each Mapifolder2 In ColMapiFolders2
If Mapifolder2.Name = "YYY YYYYYY folders" Then
Set ColMapiFolders3 = Mapifolder2.Folders
For Each MapiFolder3 In ColMapiFolders3
If MapiFolder3.Name = "XXX QXXXXXX SXXXXX" Then
Set ColMapiFolders4 = MapiFolder3.Folders
For Each MapiFolder4 In ColMapiFolders4
If MapiFolder4.Name = "Accepted" Then
With tvMail.Nodes
Set Treenode = .Add(, , "root", MapiFolder4.Name, 1)
End With
Set ColMapiFolders5 = MapiFolder4.Folders
For Each MapiFolder5 In ColMapiFolders5
With tvMail.Nodes
Set Treenode = .Add("root", tvwChild, , MapiFolder5.Name, 1)
End With
Next
End If
Next
End If
Next
End If
Next
End If
Next
Set ColMapiFolders4 = Nothing
Set ColMapiFolders3 = Nothing
Set ColMapiFolders2 = Nothing
Set ColMapiFolder = Nothing
Set MySession = Nothing
Set olNS = Nothing