Avatar of desiredforsome

asked on 

VB foreach query for string array

I am using the chilkat library for email and having some issues.

I am running a script htat is written in vb6/vba and i need it to check something.

The method is MSG.GetToAddr()

I want to load everything into a string array. Then foreach string in that array I want to run a set of commands to check. I am not running into any luck with the below code. I tkeeps giving me an error on the Next Itm.

Sub Main()
Dim database As New ADODB.Connection
Dim records As New ADODB.Recordset
Dim sql As String
Dim phones As String
Dim numto As Long
Dim recip As  Variant

On Error GoTo erl

database.ConnectionString="Provider=sqloledb; Data Source=\EMMSDE;Initial Catalog=outlookreport; User Id=jsmith; Password=s5993153492;"

If (numto > 0) Then

    For i = 0 To numto - 1
    recip = Array(MSG.GetToAddr(i))
    For Each itm In Array(MSG.GetToAddr(i))

    sql = "SELECT * FROM OUTLOOKREPORT.DBO.MFUSERS where username='" & recip & "'"

records.Open sql,database, adOpenForwardOnly, adLockReadOnly
If records.EOF=False Then

MSG.SaveEml("I:\Mail\" & MSG_UID & Format(Date,"yyyymmdd") & Format(Time,"hhmmss") & ".eml")

Next itm
'This is where we conver to eml

'End Code on it
Call AddToLog("Message Posted to Online Portal")
Email2DBAccept = True
End If
Exit Sub

    End If

'select the record we want

Call AddToLog("Script Errror: " & Err.Description)
End Sub

Open in new window

Visual Basic ClassicVB ScriptVisual Basic.NET

Avatar of undefined
Last Comment

8/22/2022 - Mon