tcl email

  • Creator
    Topic
  • #53903
    Kevin Crist
    Participant

      we use tclprocs when using the command to email someone of certain criteria in the message and we are on CL5.4.1 running on HP Unix. Would this command change if it were to run on a windows box? Basically are they different for the different environments?

      Thanks.

    Viewing 6 reply threads
    • Author
      Replies
      • #79453
        Jeff Dinsmore
        Participant

          It depends on what Tcl procs you’re using, I’m sure.

          I’ve used Tcl’s smtp/mime packages on both Windows and Linux with good success.

          Jeff Dinsmore
          Chesapeake Regional Healthcare

        • #79454
          Kevin Crist
          Participant

            below is what we use for a few of our tclprocs.

            catch [exec << $EmailMsg mailx -s $EmailSub $Emails]

          • #79455
            Jeff Dinsmore
            Participant

              That’s an external call to a unix utility program.

              Unless mailx is available on Windows, you’d need to use a different utility.

              Even if it is, you may have syntax changes to make.

              Jeff Dinsmore
              Chesapeake Regional Healthcare

            • #79456
              Jim Kosloskey
              Participant

                Kevin,

                I am not sure mailx works on Windows. I think that is a Unix command.

                Better make sure, just try to run mailx from a Dos Prompt in Windows.

                email: jim.kosloskey@jim-kosloskey.com 30+ years Cloverleaf, 60 years IT – old fart.

              • #79457
                Robert Kersemakers
                Participant

                  We are on HP-UX and mailx is definitely a unix command. I can’t find any reference to it being available for windows and I have never heard of it, but maybe there is a windows-version of it out there.

                  I am currently using mailx to send emails from cloverleaf. Haven’t checked out the available tcl packages; should give that a try.

                  Zuyderland Medisch Centrum; Heerlen/Sittard; The Netherlands

                • #79458
                  Jeff Dinsmore
                  Participant

                    Here’s the Tcl code we use for sending email.

                    It should work on Unix/Linux/Windows Tcl versions that have the mime and smtp packages available.  We’re running this code on Cloveleaf 5.6, Tcl version 8.4.12.

                    Add your specific values for defaultSmtpForwarder and defaultSmtpSender.

                    As I recall, the email server in defaultSmtpForwarder must be set up to allow forwarding for the user sending the email.

                    Code:



                    namespace eval crmcEmail {
                     
                     variable defaultSmtpForwarder
                     variable defaultSmtpSender
                     
                    }

                    proc crmcEmail::sendMessage { subject body recipientList args } {

                     global env

                     variable defaultSmtpForwarder
                     variable defaultSmtpSender
                     
                     package require smtp
                     package require mime

                     # defaults
                     set smtpSnd $defaultSmtpSender
                     set smtpServ $defaultSmtpForwarder
                     set msgStyle EMAIL
                     
                     switch -exact [llength $args] {
                       0 {
                         # no args supplied – normal operation
                       }
                       1 {
                         # Just the msg style flag supplied
                         set msgStyle [string trim [string toupper [lindex $args 0]]]
                       }
                       2 {
                         # msg style and smpt sender
                         set msgStyle [string toupper [lindex $args 0]]
                         set smtpSnd [lindex $args 1]
                       }
                       default {
                         # msg style, smpt sender AND smtp forwarder
                         set msgStyle [string toupper [lindex $args 0]]
                         set smtpSnd [lindex $args 1]
                         set smtpServ [lindex $args 2]
                       }
                       
                     }

                     # protect against empty sender
                     if { $smtpSnd eq “” } {
                       set smtpSnd $defaultSmtpSender
                     }

                     # protect against empty server
                     if { $smtpServ eq “” } {
                       set smtpServ $defaultSmtpForwarder
                     }

                     #puts “msgStyle= $msgStyle, smtpSnd= $smtpSnd, smptServ= $smtpServ”

                     if { [catch {set callingProc [lindex [info level -1] 0]} errs] } {
                       set callingProc “UNKNOWN”
                     }

                     if { [catch {set workingEnv [string toupper $env(HCISITE)]} errs] } {
                       set workingEnv “hciSiteUNDEFINED”
                     }

                     if { $msgStyle eq “TXT” } {
                       # terse txt style
                       set token [mime::initialize -canonical text/plain -string “[info hostname] [clock format [clock seconds] -format “%m/%d %H:%M”] $body”]
                       mime::setheader $token Subject “$subject”
                     } else {
                       # Standard verbose email style
                       set token [mime::initialize -canonical text/plain -string ”     Server: $workingEnv [info hostname]n[clock format [clock seconds] -format “Server Time: %m/%d/%Y %H:%M:%S”]n       proc: $callingProcnn$body”]
                       mime::setheader $token Subject “$workingEnv [info hostname] $subject”
                     }

                     mime::setheader $token From “$smtpSnd”
                     mime::setheader $token To [join $recipientList ,]
                     
                     smtp::sendmessage $token -recipients [join $recipientList ,] -servers $smtpServ -atleastone 1
                     
                     mime::finalize $token
                     
                    }

                    Jeff Dinsmore
                    Chesapeake Regional Healthcare

                  • #79459
                    Jim Kosloskey
                    Participant

                      Kevin,

                      Of course if you upgrade Cloverleaf to the current version you get the ability to email directly in the Alert which is supposed to work with all supported platforms.

                      If you are changing hardwar, maybe this is an optimum time to get current.

                      email: jim.kosloskey@jim-kosloskey.com 30+ years Cloverleaf, 60 years IT – old fart.

                  Viewing 6 reply threads
                  • The forum ‘Cloverleaf’ is closed to new topics and replies.