Hm... Språkförbistring.
Det är inte en kollektion utan ett Dictionary-objekt. (Same same, but different...?) Det är metoderna x.Exists o liknande som jag fortfarande vill behålla.
Eftersom jag sprang in i problemet att dictionary-objektet (kollektionen?) inte ville läggas i Session-objektet så gjorde jag så här:
'---för varje rad i filen, gör följande
Do While oFile.AtEndOfStream <> True
sLine = oFile.Readline
'---skapa en array med varje värde i en egen cell. separator -> ";"
sLine = Replace(sLine, ",", ";")
If Not Instr(sLine, ";") > 0 Then sLine = sLine & ";"
aLine = Split(sLine, ";")
'---skriv ut resultat, börja med radnummer
Response.Write "<I>" & getExpression("Rad", languageID, 0) & " " & nLine & ":</I> "
'If messageRecipients.Exists(Trim(aLine(0))) Then
' Response.Write getExpression("Mottagaren", languageID, 0) & " """ & Trim(aLine(0)) & """ " & getExpression("finns redan i sändlistan", languageID, 0) & ". <B>" & getExpression("Ingen import", languageID, 0) & ".</B><BR>" & vbCrLf
'---fel antal semikolon, skall vara 2 (-> 3 fält)
If Ubound(aLine) <> 2 Then
Response.Write getExpression("Fel antal semikolon", languageID, 0) & ". <B>" & getExpression("Ingen import", languageID, 0) & ".</B><BR>" & vbCrLf
ElseIf Not InStr(aLine(0), "@") > 0 Then
Response.Write getExpression("E-postadress saknas", languageID, 0) & ". <B>" & getExpression("Ingen import", languageID, 0) & ".</B><BR>" & vbCrLf
Else
Redim Preserve aRecipients(2, UBound(aRecipients, 2)+1)
'Response.Write "#" & UBound(aRecipients, 2) & "#"
aRecipients(0, UBound(aRecipients, 2)) = Trim(aLine(0))
aRecipients(1, UBound(aRecipients, 2)) = Trim(aLine(1))
aRecipients(2, UBound(aRecipients, 2)) = Trim(aLine(2))
'messageRecipients.Add Trim(CStr(aLine(0))), Trim(CStr(aLine(1)))
nImported = nImported + 1
Response.Write getExpression("Mottagaren", languageID, 0) & " """ & Trim(aLine(0)) & """ " & getExpression("importerades utan problem", languageID, 0) & ".<BR>" & vbCrLf
End If
nLine = nLine + 1
Loop
'---lägg tillbaka kollektionen i session
Session("aRecipients") = aRecipients
...och på nästa sida:
Set goodCollection = Server.CreateObject("Scripting.Dictionary")
Set noGoodCollection = Server.CreateObject("Scripting.Dictionary")
gc = 0
nc = 0
For j = 1 To Ubound(Session("aRecipients"), 2)
mMerge.Item("email") = Session("aRecipients")(0, j)
mMerge.Item("firstname") = Session("aRecipients")(1, j)
mMerge.Item("lastname") = Session("aRecipients")(2, j)
Set msg = mMerge.Expand
If msg.Send(SMTPSERVER) Then
goodCollection.Add gC, CStr(Session("aRecipients")(0, j))
gC = gC + 1
Else
noGoodCollection.Add nC, CStr(Session("aRecipients")(0, j))
nC = nC + 1
End If
Next
...men det är som sagt löst nu. Tack iaf.
------------------
To understand recursion, we must first understand recursion.