Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-30-2015, 10:15 PM
gmayor's Avatar
gmayor gmayor is offline Rule: Look for this number string and only this number string Windows 7 64bit Rule: Look for this number string and only this number string Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,142
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

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
Reply With Quote
Reply

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
Rule: Look for this number string and only this number string 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
Rule: Look for this number string and only this number string 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
Rule: Look for this number string and only this number string 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
Rule: Look for this number string and only this number string Extracting a phone number from a string that contains text and numbers. hommi16 Excel 2 06-05-2013 09:19 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:44 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft