Index: openacs-4/packages/contacts/tcl/contacts-callback-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/tcl/contacts-callback-procs.tcl,v diff -u -N -r1.54 -r1.55 --- openacs-4/packages/contacts/tcl/contacts-callback-procs.tcl 19 Dec 2006 10:54:34 -0000 1.54 +++ openacs-4/packages/contacts/tcl/contacts-callback-procs.tcl 24 Dec 2006 11:16:31 -0000 1.55 @@ -1288,14 +1288,48 @@ } else { set body $email_body(text/plain) } - + + # Deal with the files + set files "" + set import_p 0 + foreach file $email(files) { + set file_title [lindex $file 2] + set mime_type [lindex $file 0] + set file_path [ns_tmpnam] + set f [open $file_path w+] + fconfigure $f -translation binary + puts -nonewline $f [lindex $file 3] + close $f + + # Shall we import the file into the content repository ? + if {$import_p} { + } else { + lappend files [list $file_title $mime_type $file_path] + lappend filenames $file_path + } + } + + # Figure out the object_id from the subject + set email(subject) [lindex $email(subject) 0] + regexp {\#(.*?):} $email(subject) match object_id + set object_p [db_string object_p "select 1 from acs_objects where object_id = :object_id" -default 0] + if {$object_p} { + regexp {:(.*)} $email(subject) match subject + set subject [string trim $subject] + } else { + set object_id "" + set subject $email(subject) + } + acs_mail_lite::complex_send \ -from_addr $from_addr \ -reply_to $reply_to_addr \ -to_addr $to_addr \ - -subject $email(subject) \ + -subject $subject \ -body $body \ -single_email \ + -files $files \ + -object_id $object_id \ -send_immediately } }