Code:
----------------------------------------------
set chan [pop3::open -socketcmd tls::socket server.com user password]
set popuidl [::pop3::uidl $chan]
if {[llength $popuidl] == 0} {
puts "nothing"
exit
}
puts $popuidl
set popcount [expr [llength $popuidl] / 2]
if {$popcount == 1} {puts "$popcount message\n"}
if {$popcount > 1} {puts "$popcount messages\n"}
set fp [open /path/to/file.txt "a"]
foreach i [seq 1 1 $popcount] {
set popmsg [::pop3::top $chan $i 1000]
array set ::messages "$i $popmsg"
puts $fp "popcheck begin"
puts $fp $popmsg
puts [llength $popmsg]
puts $fp "popcheck end"
}
close $fp
parray ::messages
----------------------------------------------
Note: seq is a proc. With 3 messages,
[seq 1 1 $popcount] returns "1 2 3". It's a home-brewn
Tcl version of the Unix shell command.
Two problems, or rather the same problem twice.
I keep getting this error:
----------------------------------------------
list element in braces followed by "p" instead of space
while executing
"array set ::messages "$i $popmsg""
("foreach" body line 3)
invoked from within
"foreach i [seq 1 1 $popcount] {
set popmsg [::pop3::top $chan $i 1000]
array set ::messages "$i $popmsg"
puts $fp "popcheck begin"
puts $fp $pop..."
(file "checkmail.tcl" line 19)
Compilation failed.
----------------------------------------------
By elimination, I see that two lines cause the error:
array set ::messages "$i $popmsg"
puts [llength $popmsg]
If I remove the first line, the second one triggers the
exact same error.
Why?
Note that 'puts $fp $popmsg' correctly appends the
entire header and message to /path/to/file.txt.
--
Luc
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)