I have a vb script I got from purplepomegranite, which is all working very nice, I see I have a problem now that I did not see when first making the script.
The array below it gets the values for (RealName,PopServer, ReturnAddress,LoginName,Re
turnAddres
s) from a ini mail file, this works fine for most users but for users that have setup a second pop account then they will have two of each of the attributes.
What I need is if there is two attributes for each one then only get the first one it finds on each attribute, with this while loop each one will get overwritten so I will end up with the second attribute on each one.
Would be nice if I can store the first set it finds in one array and IF a second set is there store it in a 2nd array, but what I need for the most part is for it to get the 1st values it finds for each attribute (RealName,PopServer, ReturnAddress,LoginName,Re
turnAddres
s)
Is there a easy way to store the 1st one found on each, so they do not get overwritten with a 2nd if present?
Here is the array:
dim strSourceIni, strTargetIni
dim arrCopyItems
strSourceIni="D:\Mail\old-
mail.ini"
strTargetIni="C:\temp\mail
.prf"
arrCopyItems=Array(_
"DisplayName=RealName",_
"POP3Server=PopServer",_
"EmailAddress=ReturnAddres
s",_
"POP3UserName=LoginName",_
"ReplyEmailAddress=ReturnA
ddress")
dim objFSO, objR, objW, dicSourceToTarget, dicItems
set objFSO=CreateObject("Scrip
ting.FileS
ystemObjec
t")
' Populate Mappings dictionaries
set dicSourceToTarget=CreateOb
ject("Scri
pting.Dict
ionary")
set dicItems=CreateObject("Scr
ipting.Dic
tionary")
for each i in arrCopyItems
strSourceItem=LCase(Split(
i,"=")(1))
strTargetItem=LCase(Split(
i,"=")(0))
dicSourceToTarget.Add strTargetItem,strSourceIte
m
if not dicItems.Exists(strSourceI
tem) then dicItems.Add strSourceItem,""
next
' Read source ini values
set objR=objFSO.OpenTextFile(s
trSourceIn
i,1)
while not objR.AtEndOfStream
strLine=objR.ReadLine
if InStr(1, strLine, "=")>0 then
strKey=LCase(Trim(Split(st
rLine, "=")(0)))
strValue=Trim(Split(strLin
e, "=")(1))
if dicItems.Exists(strKey) then
dicItems.Remove strKey
dicItems.Add strKey, strValue
wscript.echo strKey & " = " & strValue
end if
end if
wend
objR.Close
Thanks,
Start Free Trial