do you want the entire block of text after follows or just the data side, without the labels? using (.*) should get each line in it's entirety.
This: Pattern = "((\w*)\s*(\w*))\n" looks for alpha numeric ending with a line break.
This should get everything after follows (with global = true)
. Pattern = "(request follows[:](.*))"
Edited to add the [:]
This is just so weird because it should work but it doesn't! I must have something else wrong and I'm over looking it.
I even removed the move to specific folder and assign category just to make sure it wasn't messing it up.
Here is latest code. Maybe you can see something in the wrong place or typo??? I'm scratching my head on this one.
Should be quite simple... and yes everything after the follows:
Sub CreateProjectcards()
Dim olMail As Outlook.MailItem
Dim Reg1 As RegExp
Dim M1 As MatchCollection
Dim M As Match
Dim strResult(2) As String
Dim strSubject, strFollows As String
Set Reg1 = New RegExp
Set olMail = Application.ActiveExplorer().Selection(1)
For i = 1 To 2
strResult(i) = ""
With Reg1
Select Case i
Case 1
.Pattern = "CC-(\d*)\s*(.*)"
.Global = False
Case 2
.Pattern = "(follows[:](.*))"
.Global = True
End Select
End With
If Reg1.Test(olMail.Body) Then
Set M1 = Reg1.Execute(olMail.Body)
For Each M In M1
strResult(i) = M.SubMatches(1)
Debug.Print i & ": " & strResult(i)
strSubject = strResult(1)
strFollows = strFollows & strResult(2)
Next
End If
Next i
Set myForward = olMail.Forward
myForward.To = "
userid@boards.trello.com"
myForward.Subject = strSubject
myForward.Body = strFollows
myForward.Display
Set Reg1 = Nothing
Set olMail = Nothing
Set M1 = Nothing
Set M = Nothing
End Sub