I have been working on a macro to sort inbound email into folders depending on various factors. I had successfully implemented to macro, but am in the works of refining the algorithm to make it more precise. What I want to do now is compare the folder names against the words in the email subject line. So folder "My Folder" would be the destination of a subject line that stated "Hello this is My Folder subject line". I have it all figured out except the code to find the folder name in the subject line. Here is what I have so far in a public function.
Code:
Public Function checkFunction(ByVal messageSubject As String) As Boolean
Dim match As Boolean
Dim ns As Outlook.NameSpace
Dim myfolder As Outlook.Folder
Dim mysubfolder As Outlook.Folder
Set ns = Application.GetNamespace("MAPI")
'Get the default inboxfolder
Set myfolder = ns.GetDefaultFolder(olFolderInbox)
'Loop through each folder and display name of the folder
For Each mysubfolder In myfolder.Folders
MsgBox mysubfolder.Name 'Test of where code is.
'If objSourceFolder.Item.Find(mysubfolder.Name, messageSubject) = True Then
MsgBox "Here!" 'Test of where code is.
match = True
Else
MsgBox "Not true" 'Test of where code is.
End If
Next mysubfolder
checkFunction = match
End Function