How to write a macro to search inbox for certain numbers

Status
Not open for further replies.
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?
 
E

EricLegault

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 - , MCDBA, MCTS (SharePoint programming, etc.)

"jabri" wrote:


> 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 " wrote:


> 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 - , MCDBA, MCTS (SharePoint programming, etc.)
>

>

>

> "jabri" wrote:
>
> > 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?
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
P Is it possible to write a macro to email to all addresses of selected contacts? Using Outlook 1
F Can I write a macro that triggers off an Outlook alert Outlook VBA and Custom Forms 1
P Possible to write a macro to print all attachments with specific . Outlook VBA and Custom Forms 1
S Macro to Write Rules Outlook VBA and Custom Forms 4
F VBA code to dock Styles whenever I write or edit an email Outlook VBA and Custom Forms 0
A Read and Write to Text File Outlook VBA and Custom Forms 1
F VBA routine to write new sub routine in outlook Outlook VBA and Custom Forms 0
D How Would I Write This Filter? Using Outlook 3
M how do I write a plug in to send messages to a web app? Outlook VBA and Custom Forms 1
E RE: How do i write a letter to a business contact BCM (Business Contact Manager) 1
P Write a tool to generate a PST file with the same structure as old Outlook VBA and Custom Forms 1
B Write code for a button on New Form Outlook VBA and Custom Forms 1
S write and format a piece of text in the body using vba Outlook VBA and Custom Forms 7
S Write custom text in outlook infobar Outlook VBA and Custom Forms 1
A How to write into outlook status bar. Outlook VBA and Custom Forms 1
Q Outlook become non responsive if i write outlook item in bulk Outlook VBA and Custom Forms 20
V Outlook 2007: How to read/write Out-of-Office settings Outlook VBA and Custom Forms 3
M What is the recommendet way to read/write a user defined Field (Named Property) in the MailItem Obje Outlook VBA and Custom Forms 1
M What is the recommendet way to read/write a user defined Field (Named Property) in the MailItem Obje Outlook VBA and Custom Forms 5
S Outlook 365 Help me create a Macro to make some received emails into tasks? Outlook VBA and Custom Forms 1
Geldner Send / Receive a particular group via macro or single keypress Using Outlook 1
D Auto Remove [EXTERNAL] from subject - Issue with Macro Using Outlook 17
V Macro to count flagged messages? Using Outlook 2
sophievldn Looking for a macro that moves completed items from subfolders to other subfolder Outlook VBA and Custom Forms 7
S Outlook Macro for [Date][Subject] Using Outlook 1
E Outlook - Macro - send list of Tasks which are not finished Outlook VBA and Custom Forms 3
E Macro to block senders domain Outlook VBA and Custom Forms 1
D VBA Macro to Print and Save email to network location Outlook VBA and Custom Forms 1
N VBA Macro To Save Emails Outlook VBA and Custom Forms 1
N Line to move origEmail to subfolder within a reply macro Outlook VBA and Custom Forms 0
witzker Outlook 2019 Macro to answer a mail with attachments Outlook VBA and Custom Forms 2
A Outlook 2016 Macro to Reply, ReplyAll, or Forward(but with composing new email) Outlook VBA and Custom Forms 0
J Macro to Insert a Calendar Outlook VBA and Custom Forms 8
W Macro to Filter Based on Latest Email Outlook VBA and Custom Forms 6
T Macro to move reply and original message to folder Outlook VBA and Custom Forms 6
D Autosort macro for items in a view Outlook VBA and Custom Forms 2
S HTML to Plain Text Macro - Help Outlook VBA and Custom Forms 1
A Macro to file emails into subfolder based on subject line Outlook VBA and Custom Forms 1
N Help creating a VBA macro with conditional formatting to change the font color of all external emails to red Outlook VBA and Custom Forms 5
S Visual indicator of a certain property or to show a macro toggle Outlook VBA and Custom Forms 2
L Modifying VBA script to delay running macro Outlook VBA and Custom Forms 3
S Macro to extract and modify links from emails Outlook VBA and Custom Forms 3
M Replyall macro with template and auto insert receptens Outlook VBA and Custom Forms 1
L Macro to add Date & Time etc to "drag to save" e-mails Outlook VBA and Custom Forms 17
S Macro for Loop through outlook unread emails Outlook VBA and Custom Forms 2
Globalforester ItemAdd Macro - multiple emails Outlook VBA and Custom Forms 3
S Macro to extract email addresses of recipients in current drafted email and put into clipboard Outlook VBA and Custom Forms 2
witzker HowTo start a macro with an Button in OL contact form Outlook VBA and Custom Forms 12
witzker Macro to move @domain.xx of a Spammail to Blacklist in Outlook 2019 Outlook VBA and Custom Forms 7
S Macro for other actions - Outlook 2007 Outlook VBA and Custom Forms 23

Similar threads

Top