;****
;****
;
; Docmailer.KIX
; mail reports to certain docs
;
; Note : Reads doctor info from docmailer2010.txt file
;
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-
;setup
$home = "\\vsscweb\reports\Doctor Reports"
;$FSO = createobject("Scripting.FileSystemObject")
$thismo = @monthno -1
IF $thismo = 0
$month = "12"
ELSE
IF $thismo > 9
$month = CSTR($thismo)
ELSE
$month = "0" + CSTR($thismo)
ENDIF
ENDIF
$year = IIf(@MONTHNO = 1, @YEAR -1, @YEAR)
;open log file
IF Open(2, "\\vsclinic2\mis\reports\log$month.txt",5) = 0
$w = WriteLine( 2 , "docmailer.kix started at " +@DATE + " - " + @TIME + Chr(13) + Chr(10) )
ELSE
BEEP
? "Error opening log file: [" + @ERROR + "]"
sleep 5
EXIT
ENDIF
;main program loop
$rc = SetOption("NoMacrosInStrings","On")
$rc = SetOption("NoVarsInStrings","On")
$Docs = Split(ReadProfileString("\\vsclinic2\mis\Reports\docmailer2010.txt","Docs","Names"),"#")
If UBound($docs)>=0
$Root = CreateObject("Outlook.Application")
For Each $Doc in $Docs
$docemail = ReadProfileString("\\vsclinic2\mis\Reports\docmailer2010.txt", $doc, "Email")
If Len($docemail)
$MailItem = $Root.CreateItem(0)
$MailItem.Importance = 1
; - 2 high importance
; - 1 normal importance
; - 0 low importance
$MailItem.Subject = "TEST TEST TEST Reports - !!! DO NOT REPLY !!! - this is a test of the new system"
$MailItem.Sender = "sccognos@@shannonhealth.org"
$MailItem.To = $Email
$MailItem.Body = "!!! TEST TEST TEST - DO NOT REPLY - EMAIL IS NOT MONITORED. FOR ASSISTANCE CALL 657-5041 !!!"
$Attachments = DirList("$home\$doc\(current month)",2)
If UBound($Attachments)>=0
For Each $Attachement in $Attachments
$MailItem.Attachments.Add($Attachment)
Next
Endif
$MailItem.Send
Endif
Next
$Root = 0
Endif
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; DirList() - Enumerates the files in a directory into an array. ;;;
;;; Written By: Jens Meyer ;;;
;;; http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Board=7&Number=82581 ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Function DirList($dirname, optional $options)
dim $filename, $counter, $filepath, $mask
dim $list, $sublist, $subcounter
$counter=-1
$dirname=trim($dirname)
if $dirname=''
$dirname=@CURDIR
endif
if right($dirname,1)='\'
$dirname=left($dirname,len($dirname)-1)
endif
if getfileattr($dirname) & 16
$mask='*.*'
else
$mask=substr($dirname,instrrev($dirname,'\')+1)
$dirname=left($dirname,len($dirname)-len($mask)-1)
endif
redim $list[10]
$filename=dir($dirname+'\'+$mask)
while $filename<>'' and @ERROR=0
if $filename<>'.' and $filename<>'..'
select
case (getfileattr($dirname+'\'+$filename) & 16)
if $options & 1
$counter=$counter+1
if $options & 2
$list[$counter]=$dirname+'\'+$filename+'\'
else
$list[$counter]=$filename+'\'
endif
endif
if ($options & 4)
$sublist=dirlist($dirname+'\'+$filename+'\'+$mask,$options)
if ubound($sublist)+1
redim preserve $list[ubound($list)+ubound($sublist)+1]
for $subcounter=0 to ubound($sublist)
$counter=$counter+1
if $options & 2
$list[$counter]=$dirname+'\'+$filename+'\'+$sublist[$subcounter]
else
$list[$counter]=$filename+'\'+$sublist[$subcounter]
endif
next
endif
endif
case ($options & 2)
$counter=$counter+1
$list[$counter]=$dirname+'\'+$filename
case 1
$counter=$counter+1
$list[$counter]=$filename
endselect
if $counter mod 10
redim preserve $list[$counter+10]
endif
endif
$filename = dir('')
loop
if $counter+1
redim preserve $list[$counter]
else
$list=''
endif
if $mask<>'*.*' and ($options & 4)
$filename=dir($dirname+'\*.*')
while $filename<>'' and @ERROR=0
if $filename<>'.' and $filename<>'..'
if (getfileattr($dirname+'\'+$filename) & 16)
$sublist=dirlist($dirname+'\'+$filename+'\'+$mask,4)
if ubound($sublist)+1
redim preserve $list[ubound($list)+ubound($sublist)+1]
for $subcounter=0 to ubound($sublist)
$counter=$counter+1
if $options & 2
$list[$counter]=$dirname+'\'+$filename+'\'+$sublist[$subcounter]
else
$list[$counter]=$filename+'\'+$sublist[$subcounter]
endif
next
endif
endif
endif
$filename = dir('')
loop
endif
if $counter+1
redim preserve $list[$counter]
else
$list=''
endif
$dirlist=$list
EndFunction
$ = Close (1)
$w = WriteLine( 2 , "docmailer.kix finished at " +@DATE + " - " + @TIME + Chr(13) + Chr(10) )
$w = WriteLine( 2 , " " + Chr(13) + Chr(10) )
$ = Close (2)
RETURN