This scirpt performs a query on a table. The data in the Answer table is exported to a text ASCII file and then send out via e-mail.
You need to change the query table name and fields and e-mail receipent's web address.
Var
Q Query
lError Logical
m MAIL
sMsgRecip String
sMsgSubj String
sMsgText String
sAttach String
endVar
sMsgRecip = "NameHere@address.com"
sMsgSubj = "Your data"
sMsgText = "Here is the info you have requested."
sAttach = "C:\\data.txt"
Q=Query
mytable.DB | myfield |
| Check |
EndQuery
If Not Q.ExecuteQBE() Then
MsgStop("Error","Cannot get data."

ErrorShow()
Return
EndIf
If IsEmpty("

RIV:Answer.db"

Then
MsgStop("Status","No data is found."

Return
EndIf
lError = False
Try
ExportASCIIVar("

RIV:Answer.db",sAttach)
OnFail
lError = True
EndTry
If lError Then
MsgStop("Error","Cannot export data."

Return
EndIf
m.logonDlg()
m.addAddress(sMsgRecip)
m.setSubject(sMsgSubj)
m.setMessage(sMsgText)
m.addAttachment(sAttach)
m.send() ; Send the message
m.logoff()
MsgInfo("Status","Data has been sent to "+sMsgRecip)