I need an Email Parsing Script for incoming Emails from a specific vendor. I have started the script but am having trouble with CASE 2 and CASE 3. Help please..... See specifics below:
Email Properties:
From: XXXYYYZZZ
To: AAABBBCCC
Subject: Inquiry for Property #999
Body:
Scenario 1
Property: 8505 E. San Pablo Dr
JOHN DOE, LOS ANGELES, CA, (5556021919) called to inquire about property 999
Scenario 2
Property: 8505 E. San Pablo Dr
(5556021919) called to inquire about property 999
Script Requirements:
1. Return:
· Property = 8505 E. San Pablo Dr.
· Name = JOHN DOE
· Phone = 555-602-1919
Email Parsing - Script
Sub GetValueUsingRegEx()
' Set reference to VB Script library
' Microsoft VBScript Regular Expressions 5.5
Dim olMail As Outlook.MailItem
Dim Reg1 As RegExp
Dim M1 As MatchCollection
Dim M As Match
Set olMail = Application.ActiveExplorer().Selection(1)
' Debug.Print olMail.Body
Set Reg1 = New RegExp
' \s* = invisible spaces
' \d* = match digits
' \w* = match alphanumeric
For i= 1 to 3
With Reg1
Select Case i
Case 1
.Pattern = "Property\s*[:]+\s*(\w*)\s*"
.Global = True
Case 2
.Pattern = "Property\s*[:]+\s*(\w*)\s*"
.Global = True
Case 3
.Pattern = "Property\s*[:]+\s*(\w*)\s*"
.Global = True
End Select
End With
If Reg1.test(olMail.Body) Then
Set M1 = Reg1.Execute(olMail.Body)
For Each M In M1
' M.SubMatches(1) is the (\w*) in the pattern
' use M.SubMatches(2) for the second one if you have two (\w*)
Debug.Print M.SubMatches(1)
Next
End If
End Sub
Email Properties:
From: XXXYYYZZZ
To: AAABBBCCC
Subject: Inquiry for Property #999
Body:
Scenario 1
Property: 8505 E. San Pablo Dr
JOHN DOE, LOS ANGELES, CA, (5556021919) called to inquire about property 999
Scenario 2
Property: 8505 E. San Pablo Dr
(5556021919) called to inquire about property 999
Script Requirements:
1. Return:
· Property = 8505 E. San Pablo Dr.
· Name = JOHN DOE
· Phone = 555-602-1919
Email Parsing - Script
Sub GetValueUsingRegEx()
' Set reference to VB Script library
' Microsoft VBScript Regular Expressions 5.5
Dim olMail As Outlook.MailItem
Dim Reg1 As RegExp
Dim M1 As MatchCollection
Dim M As Match
Set olMail = Application.ActiveExplorer().Selection(1)
' Debug.Print olMail.Body
Set Reg1 = New RegExp
' \s* = invisible spaces
' \d* = match digits
' \w* = match alphanumeric
For i= 1 to 3
With Reg1
Select Case i
Case 1
.Pattern = "Property\s*[:]+\s*(\w*)\s*"
.Global = True
Case 2
.Pattern = "Property\s*[:]+\s*(\w*)\s*"
.Global = True
Case 3
.Pattern = "Property\s*[:]+\s*(\w*)\s*"
.Global = True
End Select
End With
If Reg1.test(olMail.Body) Then
Set M1 = Reg1.Execute(olMail.Body)
For Each M In M1
' M.SubMatches(1) is the (\w*) in the pattern
' use M.SubMatches(2) for the second one if you have two (\w*)
Debug.Print M.SubMatches(1)
Next
End If
End Sub