Search for message using part of subject

sharky12345

Well-known Member
Joined
Aug 5, 2010
Messages
3,404
Office Version
  1. 2016
Platform
  1. Windows
I'm trying to find a way to search my Inbox for a message with a specific subject and if it's found change the subject and move it.

I've made progress and it works but only if I specify the exact subject - so does anyone know how I can search for part of the subject filed as below, (which does not work);

Code:
If oMail.Subject = "*Response Document*" Then
oMail.Subject = "Response Document* - IMPORTED 08/02/2018"
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Does that mean you would want to find items in your Inbox containing a particular string? Then, you will need to loop through the Inbox folder and then make the necessary changes. Also, please note that at times, the wildcard characters will not fetch you the right results instead you might need to depend on the built-ins or maybe use the regular expressions as required.

To loop through the inbox, you might need to do this (not tested):

Code:
For Each oInboxItems in oEntireInboxItems ' oEntireInboxItems shall be the object derived from Outlook.Application("MAPI").GetDefaultFolder(olFolderInbox).Items
     If oInboxItems.Class = olMail Then
        If InStr(1, oInboxItems.Subject, "Response Document") > 0 Then
            oInboxItems.Subject = [COLOR=#333333]"Response Document* - IMPORTED 08/02/2018"
         End If
     End If
Next oInboxItems


[/COLOR]

This is code is just to provide you on how to proceed and is not tested. Hope this helps you.
 
Upvote 0

Forum statistics

Threads
1,213,551
Messages
6,114,272
Members
448,558
Latest member
aivin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top