2

Using outlook 2010, I'd like to ensure that emails from certain internal senders go to a filtered folder, unless the "To:" field contains an internal email address.

For example

  • customer@theirdomain.com in the "To" field, [anyone]@ourdomain.com in "CC". This should go to the filtered folder.
  • customer@theirdomain.com in the "To" field, [anyone]@ourdomain.com also in the "To" field. This should not be filtered.

It's easy to filter emails by recipient if

  • Your own email address is in the To: field, or
  • You don't care which field contains the internal addresses

But in this case, I do care which field has the internal address, and I can't only apply the rule based on email sent directly to me.

Related questions

Outlook 2010 rule based only on TO field (ignore CC field)

Create rule in outlook to filter messages sent to distribution list in the 'To' field only

The latter was closed as a duplicate of

Is it possible to filter addresses in the CC field but not in the TO field?.

However IMO, this answer doesn't cover my use case.

  • Welcome to Super User. New members commonly mistake this for a service site where we will do the work. It is a Q&A community where specific questions are asked after you have attempted something and get stuck. Please add details of what you have tried so far, including scripts, code or formulas, and we will try to help. If you need more info about asking questions, check out How to Ask in the help center. – CharlieRB Sep 6 '16 at 17:18
  • This was 99% answered in by 2 very helpful posters in superuser.com/questions/806077/…. I modified their vbscript with an InStr comparison, and it works like a charm. :) @CharlieRB, is it kosher for me to post the modified vbscript as an answer here if I credit all 3 users (including the one who kindly put a bounty on it :) )? – Kirk Anderson Sep 6 '16 at 20:41
  • @KirkAnderson There's no problem with you posting your answer and crediting your sources. Thanks for contributing to Super User. – I say Reinstate Monica Sep 7 '16 at 3:14
2

Thanks to @thims and @harrymc for getting me most of the way there in Outlook 2010 rule based only on TO field (ignore CC field).

Also special thanks to @davidpostill for posting a bounty when I didn't have the rep!

Here's how I implemented their suggestions:

Sub MoveMail(Item As Outlook.MailItem)
    Dim strID As String
    Dim objMail As Outlook.MailItem

    strID = Item.EntryID
    Set objMail = Application.Session.GetItemFromID(strID)

   If InStr(1, objMail.to, "@ourdomain.com") = 0 Then
      objMail.Move Session.GetDefaultFolder(olFolderInbox).Folders("Filtered")
   End If

Set objMail = Nothing

End Sub

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.