I am trying this code to send an email with an attachment from TCL 8.6. While this code works with and without attachment in linux it fails with the following message on windows when trying to attach a file 400: cannot open crypt.dll message. Tried on windows 7, 8.1 and 10. Any idea? I appreciate your help. Google does not give any useful hints on crypt.dll
package require tls
package require smtp
package require mime
proc send_email {to subject body { attachment ""} } {
set opts {}
lappend opts -servers "smtp.something.com"
lappend opts -ports 587
lappend opts -username "someone@something.com"
lappend opts -password "password"
lappend opts -header [list "Subject" $subject]
lappend opts -header [list "From" "xyz@gmail.com"]
lappend opts -header [list "To" $to]
if { $attachment == "" } {
set mime_msg [mime::initialize -canonical "text/plain" -string $body]
} else {
set textT [mime::initialize -canonical text/plain -string $body]
set attT [mime::initialize -canonical "name=\"[file tail $attachment]\"" -file $attachment]
set mime_msg [mime::initialize -canonical multipart/mixed -parts [ list $textT $attT ]]
}
smtp::sendmessage $mime_msg {*}$opts -usetls 1
mime::finalize $mime_msg -subordinates all
}