#!/afs/ece/usr/tcl/bin/wish -f
#
# Mail sending program, Can be used as -whatnowproc 

set cwd [pwd]
if {([string match /* [info script]])} {
	set bethmail_dir [file dirname [info script]]
} else {set bethmail_dir [file dirname $cwd/[info script]]}
cd $bethmail_dir

set folder "drafts"
set w .sym1.t
set f .sym1.th_frame
source ../aux/mailth.tcl

###
set list [exec ls $mail_dir/$folder]
set this [lindex $list [expr [llength $list] -1]]
set argv "-a -i -c {elsbeth_add_module paragrath} $mail_dir/$folder/$this"
set argc [llength $argv]
set Elsbeth_Dir [file dirname [file dirname [info script]]]
set App_Name "Bsend"
source $Elsbeth_Dir/bin/elsbeth

wm title .sym1 "Mail: Send"
wm iconname .sym1 "MS"

th_label_expand_toggle $w $f.fnl

pack propagate $f 1
button $f.send -text Send -command "th_save_file $w ; exec send $TH(File,$w) ; after 100 set TH(Modified,$w) 0"
pack $f.send -side left -expand yes -fill x
pack propagate $f 0

bind . <Destroy> {if {[file exists $TH(File,$w)]} {exec rm $TH(File,$w)}}


# Wait until file starts coming in...
if {[string length [$w get 1.0 end]] == 0} {	after 1000 }
add_section_tags $w
set dash_index [string first [$w get 1.0 end] "---"]
$w tag add protect "1.0 +$dash_index chars" "1.0 +$dash_index chars lineend"

