On Windows 2000 with Windows Scripting Host enabled, you can set up a script
like:
'Begin Script
   '--------------------------------------------------
   '
   ' Sends email from the local SMTP service using CDONTS objects
   '
   ' Usage:
   '   sendmail -t <to> -f <from> -s "<subject>" -b "<message>"
   '   sendmail [-help|-?]
   '
   '--------------------------------------------------

   Option Explicit
   On Error Resume Next

   Dim objSendMail, oArgs, ArgNum
   Dim strTo, strFrom, strSubject, strBody

   Set oArgs = WScript.Arguments
   ArgNum = 0

   While ArgNum < oArgs.Count
      Select Case LCase(oArgs(ArgNum))
         Case "-to","-t":
            ArgNum = ArgNum + 1
            strTo = oArgs(ArgNum)
         Case "-from","-f":
            ArgNum = ArgNum + 1
            strFrom = oArgs(ArgNum)
         Case "-subject","-s":
            ArgNum = ArgNum + 1
            strSubject = oArgs(ArgNum)
         Case "-body","-b":
            ArgNum = ArgNum + 1
            strBody = oArgs(ArgNum)
         Case "-help","-?":
            Call DisplayUsage
         Case Else:
            Call DisplayUsage
      End Select
      ArgNum = ArgNum + 1
   Wend

   If oArgs.Count=0 Or strTo="" Or strFrom="" Or _
         strSubject="" Or strBody="" Then
      Call DisplayUsage
   Else
      Set objSendMail = CreateObject("CDONTS.NewMail")
         objSendMail.From = strFrom
         objSendMail.To = strTo
         objSendMail.Subject = strSubject
         objSendMail.Body = strBody
         objSendMail.Send
      Set objSendMail = Nothing
   End If

   ' Display the usage for this script
   Sub DisplayUsage
      WScript.Echo "Usage:"
      WScript.Echo "  sendmail -t <to address> -f <from address> -s " & _
         Chr(34) & "<subject>" & Chr(34) & " -b " & Chr(34) & _
         "<message body>" & Chr(34)
      WScript.Echo "  sendmail [-help|-?]"
      WScript.Echo ""
      WSCript.Quit
   End Sub
'End Script

and save it as c:\scripts\foomail.vbs or whatever, then call it from a batch
file with:

cscript.exe c:\scripts\foomail.vbs -t
[EMAIL PROTECTED];[EMAIL PROTECTED] -f [EMAIL PROTECTED] -s "New Web
Server Logs" -b "The Web logs for last month should now be available from
www.foo.com/weblogs. This is an automated email - if there are any problems,
please contact the Webmaster. "

Hope this helps,

Ben

> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of Stephen Turner
> Sent: 16 August 2001 10:36
> To: [EMAIL PROTECTED]
> Subject: Re: [analog-help] How do I send the report to one person's mail
> box automatically?
>
>
> On Wed, 15 Aug 2001, anny wrote:
>
> > Dear Sir,
> > I have run analog automatically every week as a cron job.
> > How do I send the report to one person's mail box automatically?
>
> It depends what operating system you're using. In Unix it's trivial:
>   analog | mail [EMAIL PROTECTED]
> I don't know how one would do it in Windows.
>
> --
> Stephen Turner               http://www.statslab.cam.ac.uk/~sret1/
>   Statistical Laboratory, Wilberforce Road, Cambridge, CB3 0WB, England
> "This is Henman's 8th Wimbledon, and he's only lost 7 matches."
> BBC, 2/Jul/01
>
> +------------------------------------------------------------------------
> |  This is the analog-help mailing list. To unsubscribe from this
> |  mailing list, go to
> |    http://lists.isite.net/listgate/analog-help/unsubscribe.html
> |
> |  List archives are available at
> |    http://www.mail-archive.com/[email protected]/
> |    http://lists.isite.net/listgate/analog-help/archives/
> |    http://www.tallylist.com/archives/index.cfm/mlist.7
> +------------------------------------------------------------------------

+------------------------------------------------------------------------
|  This is the analog-help mailing list. To unsubscribe from this
|  mailing list, go to
|    http://lists.isite.net/listgate/analog-help/unsubscribe.html
|
|  List archives are available at
|    http://www.mail-archive.com/[email protected]/
|    http://lists.isite.net/listgate/analog-help/archives/
|    http://www.tallylist.com/archives/index.cfm/mlist.7
+------------------------------------------------------------------------

Reply via email to