JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Related email:
[email protected]
,
[email protected]
I found
@Diane Poremsky
post on "
find a code in the message body, then forward
" and changed Regex pattern to suit my need
With Reg1
.Pattern = "(Related email:\s*([\w-\.]*\@[\w-\.]*)\s*)\.\s*([\w-\.]*\@[\w-\.]*)\s*)"
.IgnoreCase = True
.Global = False
However the result forward recipients is only the first email address. ie.
[email protected]
. What i need is all email addresses after the word "related to: "
What is the correct pattern to regex those email addresses
Thank you in advance
Is it all on one line /one sentence, nothing else on the line, with the address separated by colons or semicolons?
If so, this should work - if not try with just \r or \n at the end.
(Related email:\s*(.*)\r\n)
If not, how are they formatted in the line?
Is it all on one line /one sentence, nothing else on the line, with the address separated by colons or semicolons?
If so, this should work - if not try with just \r or \n at the end.
(Related email:\s*(.*)\r\n)
If not, how are they formatted in the line?
Hi Diane,
Addresses are separated by comma in one sentence.
Related email:
[email protected]
,
[email protected]
My code below:
Sub FWNew(Item As Outlook.MailItem)
Dim Reg1 As Object
Dim M1 As Object
Dim M As Object
Dim strAddress As String
Set Reg1 = CreateObject("VBScript.RegExp")
With Reg1
.Pattern = "(Related email:\s*([\w-\.]*\@[\w-\.]*)\s*)\.\s*([\w-\.]*\@[\w-\.]*)\s*)"
.IgnoreCase = True
.Global = False
End With
If Reg1.test(Item.Body) Then
Set M1 = Reg1.Execute(Item.Body)
For Each M In M1
strAddress = M.SubMatches(1)
End If
Set myForward = Item.Forward
myForward.Recipients.Add strAddress
myForward.Display
Hi
@Diane Poremsky
,
I managed to get the email addresses as my forward email recipients but encounter another error.
Run-time error '-2147467259 (80004005)': Outlook does not recognize one or more names.
However the recipients email address become send-able if I leave it awhile which I believe outlook manage to find in address books.
Been googling and check forums but seems like there is no solution to this issue. I have tried the followings
1. Disable check names
2. Custom order of checking address lists in starting with the list with most address.
Any workaround?
Thank you in advance
Dim objRecip As Recipient
Set objRecip = myForward.Recipients.Add(strAddress)
objRecip.Type = olTo ' olCC or olBCC
objRecip.resolve
Dim objRecip As Recipient
Set objRecip = myForward.Recipients.Add(strAddress)
objRecip.Type = olTo ' olCC or olBCC
objRecip.resolve
Hi Diane,
Your resolve solution does not solve the error.
I notice if strAddress is only
one
email address no issue at all but I will have at least
two
email addresses.
Your resolve solution does not solve the error.
I notice if strAddress is only
one
email address no issue at all but I will have at least
two
email addresses.