Subject: RE: Text file & Script (Update Forwarding Emails)
To create an array, I’ve put together a few tools to help.
First I dim a variant, then I add each entry to it using a delimeter not found in the data itself, like this:
“^myoldemail:mynewemail^hisoldemail:hisnewemail^etc:etc”
After I’m done I use a script library function to explode it:
Function ExplodeR5(mystr As String, comparechar As String, trimYesNo As String) As Variant
'** ParseString
'** This function works the same as @Explode -- WORKS FOR ANY STRING
'** 2004-11-01 -- Added feature to trim out blank values from list if requested as "Yes"
Dim Values List As String, returnval() As String
Dim tempstr As String, tempstrtemp As String
Dim x As Integer, y As Integer, pos As Integer
tempstr = mystr
’ Print “”
x = 0
While Not(tempstr Like "")
pos = Instr(1, tempstr, comparechar)
If (pos = 0) Then
Values(x) = tempstr
tempstr = ""
Else
REM 2004-11-01 -- Added Feature to trim out blank values if requested.
If Ucase(trimYesNo) = "YES" Then
tempstrtemp = Trim(Strleft(tempstr, comparechar))
If Trim(tempstrtemp) = "" Then
x = x - 1
Elseif Trim(Rightbp(tempstrtemp, 1)) = comparechar Then
Values(x) = Trim(Strleft(tempstr, comparechar))
tempstr = ""
Else
Values(x) = Trim(Strleft(tempstr, comparechar))
End If
If tempstr <> "" Then
tempstr = Strright(tempstr, comparechar)
End If
Else
Values(x) = Strleft(tempstr, comparechar)
tempstr = Strright(tempstr, comparechar)
End If
End If
x = x + 1
Wend
If (x >= 1) Then
Redim returnval(x-1)
For y = 0 To x-1
returnval(y) = Values(y)
Next
ExplodeR5 = returnval
Else
Redim returnval(0)
'returnval(0) = mystr
returnval(0) = ""
ExplodeR5 = returnval
End If
End Function
Now you can explode the variant by doing this:
varaint = ExplodeR5(cstr(variant), “^”, “Yes”)
Now the variant is exploded into an array and you can put the values through a for loop check. If the two e-mails are put together with a colon, you can do a simple if instr(1, persondoc.Email(0), v, “5”) > 0 Then, if matched you can then process the string strright( v, “:” ) to get the new e-mail.
Well, the works half done now.
Good Luck.
Tim Williams