![]() |
#4
|
||||
|
||||
![]()
1. OK
2. AND? I assume you mean ALL? 3. VBA text strings are case sensitive. I have assumed that case is not important. 4. OK Save the strings one to a line with their associated paths in a text file in the following format and change the code to reflect the full path and filename of the text file: David+Green+house|s:\2465\cons\ i.e. use + between the search strings and separate the path from the search with a pipe character '|'. Note folder separators are \ not / 6. I don't know what that means. The code will show a message box with the folder name 7. and will open the folder in Windows FileExplorer. You can use the test macro to test on files in the inbox, and/or use the main macro as a script associated with a rule that identifies the messages to be searched. Code:
Option Explicit Sub TestSelectedMessage() Dim olMsg As MailItem On Error Resume Next Set olMsg = ActiveExplorer.Selection.Item(1) CheckMail olMsg lbl_Exit: Exit Sub End Sub Sub CheckMail(olItem As Outlook.MailItem) Dim sSubject As String Dim sTextRow As String Dim sSearch As String Dim vSearch As Variant Dim sPath As String Dim sFileName As String: sFileName = "C:\Path\CheckList.txt" 'change as appropriate Dim iFileNo As Integer: iFileNo = FreeFile Dim i As Integer Dim j As Long Open sFileName For Input As #iFileNo sSubject = LCase(olItem.subject) Do While Not EOF(iFileNo) Line Input #iFileNo, sTextRow i = 0 sPath = Split(sTextRow, "|")(1) sSearch = Split(sTextRow, "|")(0) vSearch = Split(sSearch, "+") For j = LBound(vSearch) To UBound(vSearch) If InStr(1, sSubject, LCase(vSearch(j))) > 0 Then i = i + 1 End If Next j If i = UBound(vSearch) + 1 Then MsgBox sPath GetFolder sPath Exit Do End If Loop Close #iFileNo End Sub Sub GetFolder(strFolder As String) Shell "C:\Windows\SysWOW64\explorer.exe /root," & strFolder, vbNormalFocus lbl_Exit: Exit Sub End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
Thread Tools | |
Display Modes | |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
VBA rule to fire off in specified folder only | AndyDDUK | Outlook | 2 | 11-17-2015 10:05 PM |
![]() |
scvjudy | Word | 2 | 08-11-2014 10:58 PM |
![]() |
Eebygum | Outlook | 3 | 06-17-2013 06:10 AM |
![]() |
doppers | Outlook | 2 | 07-18-2011 05:27 AM |
Having trouble with keywords in Outlook Rule | mfarring | Outlook | 0 | 02-03-2010 08:17 AM |