ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> activetcl
activetcl
Re: [Activetcl] sending emails from window tcl
by Jeff Dinsmore other posts by this author
Dec 4 2007 12:13PM messages near this date
view in the new Beta List Site
[Activetcl] sending emails from window tcl | [Activetcl] Tcl process without console icon
Here's my library mail routine. We use is all day, every day.
 
Your mail server needs to allow forwarding of SMTP traffic.
 
namespace eval mailUtils {
 
  variable server
 
}
 
proc mailUtils::sendMessage { from recipients subject mode msg args } {
 
  variable server
 
  if { [llength $args] != 0 } {
    set server [lindex $args 0]
  } else {
    set server YourMailServerHere
  }
 
  package require mime
  package require smtp
 
  set server_time [clock format [clock seconds] -format "%D %T"]
 
  if { $mode != "terse" } {
    set str "server_time= $server_time\n$msg"
  } else {
    set str $msg
  }
  
  set someErrs 0
  if { [catch {set token [mime::initialize -canonical text/plain -string
$str]} err] } {
    errUtils::appendErr "mime::initialize Failed - err= $err"
    set someErrs 1
  }
  if { [catch {mime::setheader $token Subject $subject} err] } {
    errUtils::appendErr "mime::setheader (Subject) Failed - err= $err"
    set someErrs 1
  }
  if { [catch {mime::setheader $token From $from} err] } {
    errUtils::appendErr "mime::setheader (From) Failed - err= $err"
    set someErrs 1
  }
  if { [catch {mime::setheader $token To [join $recipients ,]} err] } {
    errUtils::appendErr "mime::setheader (To) Failed - err= $err"
    set someErrs 1
  }
  
  if { [catch {smtp::sendmessage $token -recipients [join $recipients ,]
-servers $server} err] } {
    errUtils::appendErr "mime::sendmessage Failed - err= $err"
    set someErrs 1
  }
 
  if { $someErrs } {
    return 0
  } else {
    return 1
  }
 
}

 

Jeff Dinsmore 
Interfaces 
Ridgeview Medical Center 
jeff.dinsmore@[...].org
<mailto:jeff.dinsmore@[...].org>   
952.442.2191 x6592 

 


________________________________

From: activetcl-bounces@[...].com
[mailto:activetcl-bounces@[...].com] On Behalf Of Gene
Osteen
Sent: Tuesday, December 04, 2007 10:29 AM
To: activetcl@[...].com
Subject: [Activetcl] sending emails from window tcl



All,

            What is the best way to send emails from tcl scripts in a
Windows XP Professional or 2005 Server?

 

Gene Osteen

803-649-7486

 

Confidentiality Notice: The electronic mail and/or documents
accompanying this transmission contain confidential information
belonging to the sender, which is legally privileged. The information is
intended only for the individual's) or entity named above. If you are
not the intended recipient you are hereby notified that any disclosure,
copying, distribution or taking of any action in reliance on the
contents of this information is strictly prohibited. If you have
received this transmission in error, please immediately notify us by
email or telephone to arrange for return or to destroy the original
document. Thank You.

 

 



Ridgeview Medical Center Confidentiality Notice: This email message, including any attachmen
ts, is for the sole use of the intended recipient(s) and may contain confidential and privil
eged information. Any unauthorized review, use, disclosure or distribution is prohibited. If
 you are not the intended recipient, please contact the sender by reply email and destroy al
l copies of the original message.
Thread:
Gene Osteen
Jeff Dinsmore

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved