Hi All,
I need to forward a system generated email to users in the email body. The email addresses are found right after "Related email:" and usually need to forward to 2 email addresses.
eg. Related email: abcdATgmail.com; qwer234atyahoo.com.au
I having some issue with the vba saying "Run-time error '-2147467259 (80004005)': Outlook does not recognize one or more names."
********************************************************************************
Sub FWNew(Item As Outlook.MailItem)
Dim Reg1 As Object
Dim M1 As Object
Dim M As Object
Dim objRecip As Recipient
Dim strAddress As String
Set Reg1 = CreateObject("VBScript.RegExp")
With Reg1
.Pattern = "(Related email:\s*(.*)\r\n)"
.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)
Next
End If
Set myforward = Item.Forward
Set objRecip = myforward.Recipients.Add(strAddress)
objRecip.Type = olTo
objRecip.Resolve
myforward.HTMLBody = "This is auto forward email, please do not reply" & myforward.HTMLBody
myForward.Send
*********************************************************************************
Anyone have encounter such errors before and what is the workaround?
Thank you in advance
Bookmarks