#207536 - 2013-07-29 04:19 PM
Re: Sendmail using outlook 2010
[Re: Karon]
|
Allen
KiX Supporter
Registered: 2003-04-19
Posts: 4546
Loc: USA
|
|
Top
|
|
|
|
#207538 - 2013-07-29 06:17 PM
Re: Sendmail using outlook 2010
[Re: Allen]
|
Karon
Getting the hang of it
Registered: 2009-07-16
Posts: 87
Loc: Texas
|
I added the Dirlist UDF to the script. Still not getting attachments or anything e-mailed. Outlook does launch. We are using Outlook 2010 on windows 7 pro 32bit
;****
;****
;
; 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
|
Top
|
|
|
|
#207542 - 2013-07-29 09:26 PM
Re: Sendmail using outlook 2010
[Re: ShaneEP]
|
ShaneEP
MM club member
Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
|
Also this line will fail, with the NoVarsInStrings turned on.
$Attachments = DirList("$home\$doc\(current month)",2) Change it to...$Attachments = DirList($home+"\"+$doc+"\(current month)",2)
|
Top
|
|
|
|
#207543 - 2013-07-29 09:28 PM
Re: Sendmail using outlook 2010
[Re: ShaneEP]
|
ShaneEP
MM club member
Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
|
Also the double @@'s will fail with the NoMacrosInStrings turned on.
Change the file to... [Docs] names=BOB#GEORGE#SAM
[BOB] email=bob.jones@suddenlink.net [GEORGE] email=george.hamm@gmail.com [SAM] email=sam.black@hotmail.com
Also the .Sender to...
$MailItem.Sender = "sccognos@shannonhealth.org"
|
Top
|
|
|
|
#207544 - 2013-07-29 09:58 PM
Re: Sendmail using outlook 2010
[Re: ShaneEP]
|
Karon
Getting the hang of it
Registered: 2009-07-16
Posts: 87
Loc: Texas
|
Fixed $attachments
$Attachments = DirList($home+"\"+$doc+"\(current month)",2)
Fixed @@ to @ in txt file and .Sender.
$MailItem.Sender = "sccognos@shannonhealth.org"
Still nothing being created in outlook. <SIGH>
|
Top
|
|
|
|
#207547 - 2013-07-29 11:01 PM
Re: Sendmail using outlook 2010
[Re: Karon]
|
ShaneEP
MM club member
Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
|
Don't notice anything else off the top of my head. Added a few lines to help debug the problem. Try this and see if anything looks out of place when you run it.
;****
;****
;
; 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")
$month = @monthno-1
IF $month = 0
$month = "12"
ENDIF
$month = IIf(Len($month)=1,"0"+$month,$month)
$year = IIf($month = 12, @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"),"#")
? "Elements in Docs Array: "+UBound($docs)
If UBound($docs)>=0
$Root = CreateObject("Outlook.Application")
? "Outlook Creation: "+@Error
For Each $Doc in $Docs
? "Doc: "+$Doc
$docemail = ReadProfileString("\\vsclinic2\mis\Reports\docmailer2010.txt", $doc, "Email")
? "Email: "+$docemail
If Len($docemail)
$MailItem = $Root.CreateItem(0)
? "Root Creation: "+@Error
$MailItem.Importance = 1
$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)
? "Elements in Attachment Array: "+UBound($attachments)
If UBound($Attachments)>=0
For Each $Attachement in $Attachments
$MailItem.Attachments.Add($Attachment)
? "Attachment: "+@Error
Next
Endif
$MailItem.Send
? "Send: "+@Error
Endif
Next
$Root = 0
Endif
$ = Close (1)
$w = WriteLine( 2 , "docmailer.kix finished at " +@DATE + " - " + @TIME + Chr(13) + Chr(10) )
$w = WriteLine( 2 , " " + Chr(13) + Chr(10) )
$ = Close (2)
? "Press Any Key To Exit"
get $
RETURN
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; 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
|
Top
|
|
|
|
#207548 - 2013-07-30 12:09 AM
Re: Sendmail using outlook 2010
[Re: ShaneEP]
|
Karon
Getting the hang of it
Registered: 2009-07-16
Posts: 87
Loc: Texas
|
I found a typo - Fixed and will re-run with error assistance again. I do have a question though: It does not appear that I am getting the e-mail passed to the first doc. Notice Doc: BOB does not have a corresponding Email: Doc: George does have corresponding EMail: george.hamm@@gmail.com
? "Elements in Docs Array: "+UBound($docs)
"Elements in Docs Array: "=UBound($docs)
If UBound($docs)>=0
$Root = CreateObject("Outlook.Application")
? "Outlook Creation: "+@Error
"Outlook Creation: "+@Error
Outlook Creation: 0
? "Doc: "+$Doc
"Doc: "+$Doc
$docemail = ReadProfileString("\\vsclinic2\mis\Reports\docmailer2010.txt", $doc, "Email")
Doc: BOB
? "Email: "+$docemail
"Email: "+$docemail
If Len($docemail)
Email:
Next
? "Doc: "+$Doc
"Doc: "+$Doc
$docemail = ReadProfileString("\\vsclinic2\mis\Reports\docmailer2010.txt", $doc, "Email")
Doc: GEORGE
? "Email: "+$docemail
"Email: "+$docemail
If Len($docemail)
Email: george.hamm@@gmail.com
$MailItem = $Root.CreateItem(0)
? "Root Creation: "+@Error
"Root Creation: "+@Error
$MailItem.Importance=1
Root Creation: 0
|
Top
|
|
|
|
#207554 - 2013-07-30 05:12 PM
Re: Sendmail using outlook 2010
[Re: Karon]
|
ShaneEP
MM club member
Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
|
Found another typo.
Change this line to...
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 384 anonymous users online.
|
|
|