Emailing in tcl

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Emailing in tcl

  • Creator
    Topic
  • #52277
    David Harrison
    Participant

      Cloverleaf 5.6 on Solaris 10

      I

    Viewing 5 reply threads
    • Author
      Replies
      • #73657
        Jim Rawls
        Participant

          Hi Dave,

          Check out the mutt utility in the UNIX world for emailing attachments.  We use it here.  Example:

          mutt -s “showVolumes Report” -a $HOME/statistics/gs.html -a $HOME/statistics/gs.xls jim.rawls@flhosp.org </dev/null

          Jim

        • #73658
          Robert Milfajt
          Participant

            Get info at <a href="http://www.mutt.org/&#8221; class=”bbcode_url”>http://www.mutt.org/

            If you install the man pages, then you could

            Code:

            man mutt

              😆

            Robert Milfajt
            Northwestern Medicine
            Chicago, IL

          • #73659
            David Barr
            Participant

              You can do it in TCL with the MIME package from Tcllib.

              Code:

                 package require mime
                 package require smtp

                 set psmsg [read_file report.pdf]

                 # create an image and text
                 set psT [mime::initialize -canonical
                              “application/pdf; name=”report.pdf”” -string $psmsg]
                 set textT [mime::initialize -canonical text/plain -string $body]

                 # create a multipart containing both, and a timestamp
                 set multiT [mime::initialize -canonical multipart/mixed
                                 -parts [list $psT $textT]]

                 # call Sendmail to deliver the message
                 set rcpt [list “joe_user@valleymed.org” “david_barr@valleymed.org”]
                 set rcpt2 [join $rcpt ” “]
                 set fp [open “|/usr/sbin/sendmail $rcpt2” w]
                 puts $fp “To: [join $rcpt ,]”
                 puts $fp “From: “VMC.QDX Integrator production mode.” ”
                 puts $fp “Subject: error processing report from Penrad”
                 puts $fp [::mime::buildmessage $multiT]
                 close $fp

              # The following code works from a standalone script, but not from
              # within a cloverleaf process.  In the future, I’d like to try to get
              # this working.
              #
              #     smtp::sendmessage $multiT
              #       -header [list To “David_Barr@valleymed.org”]
              #       -header [list Subject “error processing report from Penrad”]
              #       -servers { smtp.valleymed.net }
                 #    -header [list From “David_Barr@valleymed.org”]

            • #73660
              David Harrison
              Participant

                David,

                Many thanks, that works.

                I am sending a text file so could you explain the significance of “application/pdf” in this line please.

                Code:

                   set psT [mime::initialize -canonical
                                “application/pdf; name=”test.txt”” -string $psmsg]

                Thanks for the other suggestion. I’ll take a look at mutt when I have some time.

              • #73661
                David Barr
                Participant

                  When you send file attachments, you have to specify the type of attachment. I was sending a PDF attachment. It’s possible that other tools that you’ve used to send attachments in the past automatically determine the attachment type from the file suffix, but TCL doesn’t do that. If you want to send a text file, the file type is “text/plain”.

                • #73662
                  David Harrison
                  Participant

                    David,

                    Thank you that works as it should.

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