Hi,
What I'm wanting the script to do is this: extract the email address from an email, which is listed after "Email Address:" in the email, create a new message in which the recipient is that extracted email address with a new subject and the body of the email to be from an oft, then sent.
So, I need a little help. I have formulated a script with the information from other places on the forum, part of it worked one time, I made an adjustment, then the script doesn't seem to work at all, or do anything, but there are no errors that it brings up. This is what I have:
Any and all help would be greatly appreciated. I've dabbled in writing scripts before, but I'm by no means proficient in them. They are great when they work!
Thanks!
What I'm wanting the script to do is this: extract the email address from an email, which is listed after "Email Address:" in the email, create a new message in which the recipient is that extracted email address with a new subject and the body of the email to be from an oft, then sent.
So, I need a little help. I have formulated a script with the information from other places on the forum, part of it worked one time, I made an adjustment, then the script doesn't seem to work at all, or do anything, but there are no errors that it brings up. This is what I have:
PHP:
Sub First(Item As Outlook.MailItem)
Dim oItem As Outlook.MailItem
Dim Reg1 As RegExp
Dim Reg2 As RegExp
Dim M1 As MatchCollection
Dim M As Match
Dim EntryID As New Collection
Dim strID As String
Set Reg1 = New RegExp
Set Reg2 = New RegExp
strID = Item.EntryID
Set oItem = Application.Session.GetItemFromID(strID)
With Reg1
.Pattern = "(Email Address:\s*(\d*)\s*)"
.Global = True
End With
If Reg1.test(oItem.Body) Then
Set M1 = Reg1.Execute(oItem.Body)
For Each M In M1
strCode = M.SubMatches(1)
Next
End If
With Reg2
.Pattern = "([a-z0-9.]*)@([a-z0-9.]*)"
.Global = True
End With
If Reg2.test(Item.Body) Then
Set M1 = Reg2.Execute(Item.Body)
For Each M In M1
strAlias = M.SubMatches(1)
Next
End If
'------------
'Item.Subject = "New Subject Title" & strCode
'Item.Save
Set oItem = Nothing
Dim objMsg As MailItem
Set objMsg = Application.CreateItemFromTemplate("C:\Documents and Settings\Name\My Documents\First Email.oft")
objMsg.Recipients.Add strAlias & "[a-z0-9.]*)@([a-z0-9.]*)"
objMsg.Subject = "New Subject Title" & strCode
objMsg.Display '.Send
Set objMsg = Nothing
End Sub
Any and all help would be greatly appreciated. I've dabbled in writing scripts before, but I'm by no means proficient in them. They are great when they work!
Thanks!