View Single Post
  #3  
Old September 30th 06, 08:05 AM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default Creating macro that will sort emails into folders based on text in body

Am 29 Sep 2006 12:58:37 -0700 schrieb mugginns:

This basic loops through the Inbox. The loop counts backwards because I
guess that you want to move found items off that list.

Dim Item as Object
Dim Folder as Outlook.MapiFolder
Dim Target as Outlook.Folder
Dim i as Long
Dim Find as string

Set Folder=Application.GetDefaultFolder(olFolderinbox)

Find="hospid= 102431"

' If hosp11 is a subfolder of the Inbox
Set Target = Folder.Folders("hosp11")

For i=Folder.Items.Count To 1 Step-1
Set Item=Folder.Items(i)
If Instr(1, Item.Body, Find, vbTextCompare) Then
Item.Move Target
Endif
Next

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.VBOffice.net --


I'm trying to find a good spot to find info on how to create a macro
that will basically look through the body of an email and sort it into
a folder based on finding a string, ie:

hospid= 102341

It would then be sent to a folder, ie:

hosp11

I'm a little new at programming for Outlook and was wondering if anyone
can help me out. I had looked at a post on outlookcode.com that
basically creates your own rules but i could not get this to work at
all, and I'm not sure if it was searching the body for the information
or not.

michael

Ads