|
-
May 24th, 2005, 08:15 AM
#1
Thread Starter
New Member
Parsing email body text for data
Hi All,
New to the forum. I've used Sue Mosher's ParseTextLinePair function (see below) before to retrieve data from the results of a web form that has been emailed to me but I've always sought ALL the data that appears after the data label. Eg. if the body of the email says:
NAME: John Smith
POSITION: Manager
I get "John Smith" from specifying strLabel as "NAME: " in my code. However I'm now looking to get just "John" so I'm guessing I need to try and swap the vbCrLf in the code below for a space somehow.
Anyone have any ideas how?
Cheers
Bob
Code:
Function ParseTextLinePair(strSource As String, strLabel As String)
Dim intLocLabel As Integer
Dim intLocCRLF As Integer
Dim intLenLabel As Integer
Dim strText As String
intLocLabel = InStr(strSource, strLabel)
intLenLabel = Len(strLabel)
If intLocLabel > 0 Then
intLocCRLF = InStr(intLocLabel, strSource, vbCrLf)
If intLocCRLF > 0 Then
intLocLabel = intLocLabel + intLenLabel
strText = Mid(strSource, intLocLabel, intLocCRLF - intLocLabel)
Else
intLocLabel = Mid(strSource, intLocLabel + intLenLabel)
End If
End If
ParseTextLinePair = Trim(strText)
End Function
-
May 24th, 2005, 09:19 AM
#2
Frenzied Member
Re: Parsing email body text for data
You could use Replace() to swap the space for a vbcrlf, or Split() to break a string into an array based on a delimiter, such as a space. There should be examples in Help. The exception is if you're using a MS Office app 97 or before, which doesn't have those functions. If so, there's a Split sub in the VB6 codebank you could use.
Tengo mas preguntas que contestas
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|