If you have Outlook installed on the same machine that sends emails it
very easy with CAWT:
package require cawt
set appId [Outlook Open]
set mailTextId [Outlook CreateHtmlMail $appId [list $EMail] $subject
$body $attachmentList]
Outlook SendMail $mailTextId
You can also use pure Tcl to send mails directly through the mail
server.
This is my code, except for the true mail adress and password:
# This script sends a text/html formated email with a zip or pdf file
attached (optionally)
package require mime
package require smtp
set to [string trim [lindex $argv 0]]
set subject [lindex $argv 1]
set body [lindex $argv 2]
set attachment [lindex $argv 3]
set bcc [string trim [lindex $argv 4]]
set from [string trim [lindex $argv 5]]
set enc [string trim [lindex $argv 6]]
set pass [string trim [lindex $argv 7]]
if {$from==""} {
set from
default@domain.com
}
if {$enc==""} {
set enc cp1252
}
if {$pass==""} {
set pass yourpassword
}
proc sendmail {to subject body {attachment ""} {bcc {}} {from
default@domain.com} {enc cp1252} {pass ""}} {
set opts {}
lappend opts -servers [list smtp.office365.com]
lappend opts -ports [list 587]
lappend opts -usetls 1
lappend opts -username
default@domain.com
lappend opts -password yourpassword
lappend opts -header [list "Subject" [mime::word_encode $enc quoted-printable $subject]]
lappend opts -header [list "From" $from]
lappend opts -header [list "To" $to]
if {[llength $bcc]} {
lappend opts -header [list "Bcc" $bcc]
}
# lappend opts -debug 1
if {$attachment==""} {
set mime_msg [mime::initialize -canonical "text/html" -param [list charset $enc] -encoding "8bit" -string $body]
} else {
set apptype [string trim [file extension $attachment] .]
set mime_body [mime::initialize -canonical "text/html" -param
[list charset $enc] -encoding "8bit" -string $body]
set mime_zip [mime::initialize -canonical "application/$apptype; name=\"[file tail $attachment]\"" -file $attachment]
set mime_msg [::mime::initialize -canonical "multipart/mixed"
-parts [concat $mime_body $mime_zip]]
}
smtp::sendmessage $mime_msg {*}$opts -queue false -atleastone false
-usetls true -debug 0
mime::finalize $mime_msg
}
sendmail $to $subject $body $attachment $bcc $from $enc $pass
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)