I need to perform a text-parsing operation of the body of every message in an outlook folder.
I have figured out how to access the folder's count property through the Items collection object. I can even use the GetFirst method on the Items collection to access the body of the first MailItem, but I can't quite figure out how to get the program to loop through every MailItem in the folder.
Dim myOlApp As Outlook.Application
Dim myNameSpace As Outlook.NameSpace
Dim myFolders As Outlook.Folders
Dim FolderINeed As Outlook.MAPIFolder
Dim myMailItem As Outlook.MailItem
Dim strText As String
Set myOlApp = CreateObject("Outlook.Application"
Set myNameSpace = myOlApp.GetNamespace("MAPI"
Set myFolders = myNameSpace.Folders.Item(1).Folders
Set FolderINeed = myFolders.Item("Name of Main Folder"
.Folders.Item("Name Of Subfolder"
counter = NamaFolder.Items.Count
Set myMailItem = FolderINeed.Items.GetFirst
For i = 1 To counter
strText = myMailItem.Body
'Perform necessary operation
'Get the next MailItem in the FolderINeed
Next
I have figured out how to access the folder's count property through the Items collection object. I can even use the GetFirst method on the Items collection to access the body of the first MailItem, but I can't quite figure out how to get the program to loop through every MailItem in the folder.
Dim myOlApp As Outlook.Application
Dim myNameSpace As Outlook.NameSpace
Dim myFolders As Outlook.Folders
Dim FolderINeed As Outlook.MAPIFolder
Dim myMailItem As Outlook.MailItem
Dim strText As String
Set myOlApp = CreateObject("Outlook.Application"
Set myNameSpace = myOlApp.GetNamespace("MAPI"
Set myFolders = myNameSpace.Folders.Item(1).Folders
Set FolderINeed = myFolders.Item("Name of Main Folder"
counter = NamaFolder.Items.Count
Set myMailItem = FolderINeed.Items.GetFirst
For i = 1 To counter
strText = myMailItem.Body
'Perform necessary operation
'Get the next MailItem in the FolderINeed
Next