![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
![]()
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 |
#2
|
|||
|
|||
![]()
Here's some sample code that can move an e-mail to the folder you choose if
it contains the specified text in the message body: Dim objMail As Outlook.MailItem 'Look for open item window If ActiveInspector Is Nothing Then Exit Sub 'Look for open e-mails only If ActiveInspector.CurrentItem.Class olMail Then Exit Sub Set objMail = ActiveInspector.CurrentItem If InStr(objMail.Body, "Look for this text") 0 Then 'will move to the folder you choose Call objMail.Move(Application.GetNamespace("MAPI").Pick Folder) 'You can replace the above Move argument with a MAPIFolder object directly instead of choosing one 'Use NameSpace.GetDefaultFolder to easily get a reference to a default Outlook folder If Err.Number 0 Then 'A folder wasn't chosen, or a non-email folder was chosen End If End If -- Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ "mugginns" wrote: 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 |
#3
|
|||
|
|||
![]()
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 |
#4
|
|||
|
|||
![]()
Thanks for the help gentlemen. I'm looking at the code, and I'm looking
specifically at: 'You can replace the above Move argument with a MAPIFolder object directly instead of choosing one 'Use NameSpace.GetDefaultFolder to easily get a reference to a default Outlook folder Basically I want to send the file to a folder called "blank1" that I have created in my Inbox. I have looked and looked but I cannot understand how to use this. Can you help explain ? Michael |
#5
|
|||
|
|||
![]() |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Forward emails based on text in body of e-mail | [email protected] | Outlook and VBA | 0 | August 24th 06 05:37 PM |
Outlook 2003 sending blank emails / text missing from body | Keith | Outlook - General Queries | 3 | June 1st 06 02:57 PM |
Duplicate emails with different text body | Martin | Outlook - General Queries | 2 | May 28th 06 11:35 PM |
I want to certify a macro based document & don't want to see Mess | Parag Vidhate | Outlook and VBA | 1 | May 27th 06 04:22 AM |
Macro to Flag based on criteria | [email protected] | Outlook - General Queries | 1 | March 31st 06 03:04 AM |