Index by: file name | procedure name | procedure call | annotation
javaMail_proc.tcl (annotations | original source)


namespace eval javaMail {

    proc javaMail { emailAddress subject body } { 

	    java::import java.util.Properties
	    java::import javax.mail.Message
	    java::import javax.mail.Session
	    java::import javax.mail.Transport
	    java::import javax.mail.internet.InternetAddress
	    java::import javax.mail.internet.MimeMessage
	    
	    set PropertiesI [ java::new Properties ]	
	    set emailServer xxxxxxxx.xxx.xxxxx 
	    
	    $PropertiesI put "mail.smtp.host" $emailServer

	    set SessionI [ java::call Session getDefaultInstance $PropertiesI [ java::null ] ]
	    #$SessionI setDebug true

	    set MessageI [ java::new MimeMessage $SessionI ]
	    
	    set InternetAddressFromI [ java::new InternetAddress [ info host ] ]
	    set InternetAddressToI   [ java::new InternetAddress $emailAddress ] 	

	    $MessageI setRecipient [ java::field Message.RecipientType TO ] $InternetAddressToI
	    $MessageI setSubject   $subject 

	    if { [ file isfile $body ] ==1 } {

	        set body [ read [ open $body r ] ]	

	    } else {

	      	set tx "body is text"

	    }

	    $MessageI setContent $body "text/plain"

	    java::call Transport send $MessageI 

    }

}

Index by: file name | procedure name | procedure call | annotation
File generated 2007-08-07 at 13:42.