How to write a macro to search inbox for certain numbers

J

jabri

Never written a macro in outlook before.
I'm sure this is pretty basic.
How would I write code to highlight everything in my inbox and search for
45678.
I would then take all of those emails and copy them to another folder and
then do another search for 45679 and do the same thing over and over with a
list of numbers. I would have to modify the list daily from an excel file.

Is this possible?
 
J

jabri

So to be very step by step
just have my inbox open
Go to Tools/Macro/Macros
Macro name =test
Create

Sub test()
ActiveExplorer.Search("45678",
Outlook.OlSearchScope.olSearchScopeCurrentFolder)
End Sub


Eric Legault said:
It's actually pretty simple, one line of code:

ActiveExplorer.Search("My search text",
Outlook.OlSearchScope.olSearchScopeCurrentFolder)

See the developer reference for more information:

Search Method [Outlook 2007 Developer Reference]:
http://msdn.microsoft.com/en-us/library/bb220302.aspx


--
Eric Legault - Outlook MVP, MCDBA, MCTS (SharePoint programming, etc.)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


jabri said:
Never written a macro in outlook before.
I'm sure this is pretty basic.
How would I write code to highlight everything in my inbox and search for
45678.
I would then take all of those emails and copy them to another folder and
then do another search for 45679 and do the same thing over and over with a
list of numbers. I would have to modify the list daily from an excel file.

Is this possible?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top