Tk Library Source Code

Attachment Details
Login
Overview

Artifact ID: be539b8a3122ae25f2617c1a1892999b995100e4
Ticket: 1376323fffffffffffffffffffffffffffffffff
Date: 2005-12-09 00:09:29
User: andreas_kupries
Artifact Attached: 71b35cfa9ceb9b963b6eb0d7b987b4f52844d5e4
Filename:smtp_error_code_snippet.txt
Description:Code for sending mail
Content:
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
package require smtp
package require mime

#---------------------------------------------------------------- winSendMail
#
# Sends email to the specified list of addresses
#
# INPUT:	to	- A list of email addrs of the primary recipients
#		cc	- A list of email addrs of BCC recipients
#		bcc	- A list of email addrs of BCC recipients
#		subj	- The subject line
#		body	- The message body (if this string looks like a
#		file	- Flag; 0 if body is just text, 1 if body is path to file
#
# RETURN:	1 - Send failed
#		0 - Send succeeded
#
# PUBLIC
#
proc winSendMail { to cc bcc subject body { file 0 } } {
    
  global TtMailBox

  if { $file } { set filename $body; set body [ readFile $body ] }
  
  set server    <hidden>
  set user      <hidden>
  set passwd    <hidden>
  set fullname  <hidden>
  set emailaddr <hidden>
    
  set token [ mime::initialize -canonical text/plain -string $body ]

  mime::setheader   $token Subject $subject
  mime::setheader   $token Date [clock format [clock seconds] -format "%a, %d %b %Y %H:%M:%S -0800"]
  if { $cc  != "" } { mime::setheader   $token cc $cc -mode append }
  if { $bcc != "" } { mime::setheader   $token bcc $bcc -mode append }
  
  set unmailed [ smtp::sendmessage $token -recipients $to -servers $server -username $user -password $passwd -originator "\"$fullname\" <$emailaddr>" ]
		
  mime::finalize    $token

  if { $unmailed != "" } { set TtMailBox(ERROR) $unmailed; return 1 }

  return 0

}