Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > VBA / Office Integration > Word, PowerPoint, Outlook, and Other Office Products > Outlook VBA - Searching for a String


Reply
 
Thread Tools Display Modes
  #1  
Old 11-10-2003, 11:54 AM
Rollin Rollin is offline
Regular
 
Join Date: Nov 2003
Posts: 56
Default Outlook VBA - Searching for a String


Is there a way to code Outlook to automatically search through the body of an email I recieve to look for a certain string or certain set of characters? I recieve about 40 emails at work daily with each email containing many lines of information pertaining to work orders. Most of the information contained in the email is useless to me. I am only interested in the string of characters contained after the word NODE and before the word IP. Below is a small sample portion of the body of one of the emails. The body of the actual email is actually much longer so I would like to write a macro that will seach the entire body and locate each of the strings that are bolded below which ALWAYS always appear after the word NODE and before the word IP. After finding each of these strings I would like to write them to either a text or Excel file. Can this be done? I have very little experience coding with Outlook but am pretty familiar with using VBA with Excel and Word.



Thanks,
Rollin

******************************************************
SAMPLE EMAIL DATA


GQE Data=>
1068182720=>0=>>>GQE HIT=>3245:2:15:8:37=>Seen=>6=>Times In=>60=>Secs
1068182720=>0=>>>GQE NODE=>TUKRGAMA72W=>IP=>00.00.00.00=>CONN=>nms7709930921-8-35
1068182720=>0=>>>GQE INFO=>slot=10 port=4 vpi=8 vci=37
1068182720=>0=>>>GQE FABRIC=>itt addr: 0x8aa5, tgid: 0x8, oam: 0xc3, itt key: 0x27, cid:0xcad, oid:0x0


1068182736=>0=>>>GQE HIT=>7542:0:12:8:77=>Seen=>39=>Times In=>60=>Secs
1068182736=>0=>>>GQE NODE=>TUKRGAMA72W=>IP=>00.00.00.00=>CONN=>nms7704957911-8-35
1068182736=>0=>>>GQE INFO=>slot=11 port=4 vpi=8 vci=77
1068182736=>0=>>>GQE FABRIC=>itt addr: 0x824d, tgid: 0x8, oam: 0xc3, itt key: 0x19, cid:0x1d76,

Last edited by Rollin; 11-10-2003 at 12:02 PM.
Reply With Quote
  #2  
Old 11-10-2003, 12:13 PM
Wamphyri's Avatar
Wamphyri Wamphyri is offline
Variable not defined

Retired Moderator
* Guru *
 
Join Date: Apr 2002
Location: Ottawa, Ontario
Posts: 4,793
Default

You could find the info using the function InStr() and grab that info using Mid$()
Code:
Dim sBody As String Dim lPos As Long 'Get the body of your email 'You'll need to use the Outlook Object library sBody = YourMailItem.Body 'Find NODE=> lPos = InStr(sBody, "NODE=>") 'Keep looping until no longer found Do While lPos 'Here you'd output to the text file or excel file instead of Debug.print Debug.Print Mid$(sBody, lPos + 6, InStr(lPos, sBody, "=>IP=>") - (lPos + 6)) 'Find NODE=> lPos = InStr(lPos + 1, sBody, "NODE=>") Loop
You can check out this thread for help on Outlook.

A quick search of the site for outlook will provide many more examples. Or you could search threads that JordanChris or I have replied to many of our threads deal with Outlook.
__________________
-Carl

Last edited by Wamphyri; 11-10-2003 at 12:23 PM.
Reply With Quote
  #3  
Old 11-10-2003, 01:44 PM
Rollin Rollin is offline
Regular
 
Join Date: Nov 2003
Posts: 56
Default

Wamphyri,

Thanks for your help. I got my macro working exactly like I wanted. You have helped make my life easier and now there is more time to nap at work


Rollin
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleting a file in dat question ? murphys General 5 11-06-2002 08:34 PM
Open an associated Text Document knoxitis General 19 05-01-2002 11:26 PM
Shareware Registry Protection Technigue karachi999 General 2 01-21-2002 02:40 PM
Loop to format file kingesk General 2 09-10-2000 05:01 PM
File format problem kingesk General 1 09-08-2000 04:52 PM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->