# $Header: /home/cvsroot/tcldb/wisql/Tlib/doMailResultsTo,v 1.3 1998/03/14 08:17:34 de Exp $
# tcl procs saved on Tue Sep 05 09:32:37 PDT 1995

proc doMailResultsTo {} {

global exedir
global uname
  global MsgW
  
  if {[.m.o.out get 1.0 end]==""} {
    setMsg $MsgW "No output to send"
    return
  }

# DC hack to get some kind of header into output files

  set datetime ""
  catch {set datetime [exec date]}

  if {$datetime == ""} {
  set banner "WISQL output: Date function not available via exec on this host.\n
\n"
  } else {
  set banner "WISQL output: $datetime run by [id user] as Sybase user $uname\n\n
"
  }

  .m.o.out insert 1.0 "$banner\n"

  set w .getuseraddress
  set title "Mail To Whom?"
  catch {destroy $w}
  toplevel $w -class Dialog
  wm title $w $title
  wm geom $w "200x150+200+200"


    set font [getFont $w smallertim]
    message $w.prompt -justify center  -font "$font" -text "Enter Recipient" -aspect 600

#       create the user input area
    set font [getFont $w mediumhel]
    entry  $w.input -font $font -relief sunken -width 20 -border 1

    bind $w.input <Shift-Return> "$w.control.ok invoke"

#       control frame

    frame $w.control -relief raised -border 1

    button $w.control.ok -text OK -relief raised -border 2  -command "mailText .m.o.out \[$w.input get\]; destroy $w" -padx 0 -pady 0
    button $w.control.can -text Cancel -relief raised -border 1  -command "destroy $w" -padx 0 -pady 0

    pack $w.control.can -side left -expand true -fill x  
    pack $w.control.ok -side left -expand true -fill x

    pack $w.prompt -side top -fill both -expand true
    pack $w.input -side top -expand true -fill x
    pack $w.control -side top -fill both -expand true


    focus $w.input

}

