Thursday, August 11, 2011


Function that verifies an email is available in the MSSQL database:


Public Function Database()
Dim con,rs,i
'Opening the ADODB Connection
Set con=createobject("adodb.connection")
'Creating the Recordset object
Set rs=createobject("adodb.recordset")
'Opening the conenction
con.open "provider=sqloledb.1;server=server_ip;uid=sql_user;pwd=password;database=database_name"
'Executing the query against the database opened
rs.open "select*from [database_name].[dbo].[table] where (name like 'test%' or name like 'func') and date>=getdate()-1",con
'Looping through all the values of 1st and 2nd column values
i=0
Do while not rs.eof
'verifying email and attachment are in the database
If (InStr(rs.fields("name"),"test") or InStr(rs.fields("name"),"func")) then
If InStr(rs.Fields("location"),"Administrator/Inbox") or  InStr(rs.Fields("location"),"Administrator/Sent Items"Then
database = true
else
database = false
End If
End If
        rs.Movenext
Loop
wait 5
End Function

No comments:

Post a Comment