![]() |
|
|
|
#1
|
||||
|
||||
|
You only need the one rule. You can set the searches in the script.
You can loop through a list of numbers and apply the corresponding e-mail addresses. I assume they are all going to the same folder, if not you will need to treat the folders in the same way with a matching folder for each number. The following is not tested, but should work. Code:
Sub MoveToFolder(olMail As Outlook.MailItem)
Dim strText As String
Dim olOutMail As Outlook.MailItem
Dim olInsp As Outlook.Inspector
Dim wdDoc As Object
Dim oRng As Object
Dim iCount As Long
Dim vEmail As Variant
Dim vNum As Variant
Dim i As Long
Const strFolder As String = "1 Rating Folder" 'folder must exist
Const strNum As String = "<5555>|<1111>" 'separate search strings with '|'
Const strEmail As String = "jane@example.com|mike@example.com" 'Corresponding e-mail addresses to strNum
strText = "1 rating" 'Common folder
vEmail = Split(strEmail, "|")
vNum = Split(strNum, "|")
Set olInsp = olMail.GetInspector
Set wdDoc = olInsp.WordEditor
For i = LBound(vNum) To UBound(vNum)
With olMail
iCount = 0
Set oRng = wdDoc.Range
With oRng.Find
Do While .Execute(FindText:=vNum(i), MatchWildCards:=True)
iCount = iCount + 1
Exit Do
Loop
End With
Set oRng = wdDoc.Range
With oRng.Find
Do While .Execute(FindText:=strText, MatchWildCards:=False, MatchCase:=False)
iCount = iCount + 1
Exit Do
Loop
End With
End With
If iCount = 2 Then
Set olOutMail = olMail.Forward
With olOutMail
.To = vEmail(i)
.sEnd
End With
olMail.Move Session.GetDefaultFolder(olFolderInbox).folders(strFolder)
End If
Next i
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 |
|
| Tags |
| rule |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to find number of coma and then add that number of rows in word using macro? | PRA007 | Word VBA | 7 | 05-27-2015 10:45 PM |
Heading's Footnote's number is displayed in TOC. How to remove the number in TOC?
|
Orehrepus | Word | 1 | 07-13-2014 12:51 PM |
How to create a table with a number of line depending a number entered by user
|
Cellendhyll | Word Tables | 3 | 07-10-2014 05:49 AM |
Way to search for a string in text file, pull out everything until another string?
|
omahadivision | Excel Programming | 12 | 11-23-2013 12:10 PM |
Extracting a phone number from a string that contains text and numbers.
|
hommi16 | Excel | 2 | 06-05-2013 09:19 PM |