question

Joel-5954 avatar image
0 Votes"
Joel-5954 asked Joel-5954 commented

Outlook advanced rules for client codes

My advertising company has client codes for Radio and TV: for example PRAE00001T for TV spots or PRAE00002R for radio spots. There is always a 4 letter client code followed by 5 digit spot number that ends with a R for radio or T for TV.

Is it possible to add a rule to Outlook that moves all the radio spots into their own folder?

I'm new to using rules so feel free to assume I don't know the basics. I'm using Outlook app on a PC.

Thank,
-Joel

office-outlook-itprooffice-addins-dev
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

JadeLiang-MSFT avatar image
0 Votes"
JadeLiang-MSFT answered Joel-5954 commented

Hi @Joel-5954,

Welcome to our forum.

for example PRAE00001T for TV spots or PRAE00002R for radio spots

Where were these client codes in your emails(emails subject, emails content or sender address)? And are these 4 letters a fixed value-"PRAE"?

For your requirement, we may need to create a rule with wildcards, which is actually not supported on Outlook based feature. In this case, we could try to use wildcards in a script, and create a rule to run this script automatically. Based on my research, I found a related article : To create a rule with wildcards (Please Note: Since the web site is not hosted by Microsoft, the link may change without notice. Microsoft does not guarantee the accuracy of this information.)

If your client code is in your subject and the 4 letter is fixed, I have tried to modify the script and test on my Outlook 365, and found it could work for me---messages' subject with "PRAE?????T" would move to T folder under Inbox, messages' subject with "PRAE?????R" would move to R folder under Inbox. For your reference:

 Sub MoveInvoices(Item As Outlook.MailItem)
 Dim MoveFolder As Folder
 Set MoveFolder = Session.GetDefaultFolder(olFolderInbox)
 Set MoveFolder_t = MoveFolder.Folders("T")
 Set MoveFolder_r = MoveFolder.Folders("R")
      If LCase(Item.Subject) Like LCase("*#####T*") = True Then
       Item.Move MoveFolder_t
   End If
    If LCase(Item.Subject) Like LCase("*#####R*") = True Then
       Item.Move MoveFolder_r
   End If
 End Sub

You could paste this script in your visual basic pane(Alt+F11) in Outlook, save it and create a rule to run this script(Rules>Manage rules and Alerts>Apply this rule for the messages I receive>choose condition for your need, or you could not choose it and the rule would apply to all messages you received>choose action "run a script", choose this script>apply).

Hope that would be helpful to you.


If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

· 7
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I'm so excited to try this! Yes, the client codes are in the subject. There are hundreds of client codes, so PRAE is not a fixed value.

Would I replace (PRAE?????T) with (?????????T)?

Thanks so much for the time you have spent on this! I'm excited to clean up my emails and to have learned something new!

0 Votes 0 ·

OK, so far I'm not having any luck. I'll tell you the steps I have taken so far.

  1. Alt+F11 in outlook>Right click Project1>Insert>Module>Copy & Paste above code>Rename ("PRAE?????T") to ("?????????T")>Save

  2. Create 2 new folders R and T

3.New rule>step 1 condition select none>step 1 action select run a script>step 2 actions select Project1.MoveInvoices> no exceptions>Run this rule now>Finish.

Anything that I missed or did incorrectly?

Thanks again for all the time you put into this! I'll read the article you sent about wild cards and keep playing with it in the meantime.

0 Votes 0 ·

Hi @Joel-5954,
Thanks for your update, I have continued to researched a lot about wildcard and found we could use "#" to represent the digit, and we could use "#####T" to match all words with 5 digits and ending with T, but if the 4 letter is not a fixed value, the "* " and " ?" before seems to be meaningless, because "?" seems to could represent all characters, I think it would be better to fix at least a letter to match more precise words.
If we could match these subjects via the last 5 digits and "T" , and it would not cause confusion to other emails in your mailbox, you could refer to my updated script on my answer above.

Also, if you still would like to modify it for your specific requirement and need more information about wildcard, you could refer to this article: Examples of wildcard characters


0 Votes 0 ·
Show more comments