I can email a query by scheduling a command in scheduled tasks that runs a macro to send object. The only stipulation is that I have to be logged in with Outlook open for it to work. I want to run the task on a server with SMTP installed without having to be logged in and be able to send the message from a certain email address. I have some VB code that will send a message throught the SMTP server but not an attachment. I'm using MS Access 2000 on Windows 2K. Can any one help?
...later post to other forum
I found a solution (if you call it that): I had to use a scheduled task to open a macro, which runs a module, which exports the query results to a file and runs a batch file, the batch file runs a vb script that sends the query results to designated recipients using SMTP server.
THERE MUST BE A BETTER WAY!
The VB script would not run in Access and I couldn't run the .VBS from Access.
LD.vbs file:
Set objMail = CreateObject("CDONTS.NewMail"
objmail.to = "x@gaf.com"
objmail.from = "ContactAdmin@gaf.com"
objmail.subject = "Daily Contact Report"
objmail.attachfile "\\burga2ks02 _
\csd\qryContactNeeded-LD.xls"
objmail.send
Set objMail = Nothing
------------------------------------------------------------
Access function:
'Outputs query results to xls and runs a batch file that _
'runs a vbs script to send the file to the appropriate user.
Function SendObject()
On Error GoTo SendObject_Err
If (DCount("*", "qryContactNeeded-LD"
> 0) Then
DoCmd.OutputTo acQuery, "qryContactNeeded-LD", "MicrosoftExcel(*.xls)", _
"\\burga2ks02\csd\qryContactNeeded-LD.xls", False, ""
Call Shell("e:\customerservicedatabase\LD.bat", 6)
End If
SendObject_Exit:
Exit Function
SendObject_Err:
MsgBox Error$
Resume SendObject_Exit
End Function
------------------------------------------------------
Your help is much appreciated,
Brent
...later post to other forum
I found a solution (if you call it that): I had to use a scheduled task to open a macro, which runs a module, which exports the query results to a file and runs a batch file, the batch file runs a vb script that sends the query results to designated recipients using SMTP server.
THERE MUST BE A BETTER WAY!
The VB script would not run in Access and I couldn't run the .VBS from Access.
LD.vbs file:
Set objMail = CreateObject("CDONTS.NewMail"
objmail.to = "x@gaf.com"
objmail.from = "ContactAdmin@gaf.com"
objmail.subject = "Daily Contact Report"
objmail.attachfile "\\burga2ks02 _
\csd\qryContactNeeded-LD.xls"
objmail.send
Set objMail = Nothing
------------------------------------------------------------
Access function:
'Outputs query results to xls and runs a batch file that _
'runs a vbs script to send the file to the appropriate user.
Function SendObject()
On Error GoTo SendObject_Err
If (DCount("*", "qryContactNeeded-LD"
DoCmd.OutputTo acQuery, "qryContactNeeded-LD", "MicrosoftExcel(*.xls)", _
"\\burga2ks02\csd\qryContactNeeded-LD.xls", False, ""
Call Shell("e:\customerservicedatabase\LD.bat", 6)
End If
SendObject_Exit:
Exit Function
SendObject_Err:
MsgBox Error$
Resume SendObject_Exit
End Function
------------------------------------------------------
Your help is much appreciated,
Brent