snippets

Check-in [c9723faeb5]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:added some old dde snippets from Jun 2007
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: c9723faeb5db3c1536000584f26edd2e706c96f4fb9a837f580c554054f4fb40
User & Date: alex 2018-08-15 13:19:19
Context
2018-08-15
14:03
tdom nodecmd examples check-in: ea9356c3c9 user: alex tags: trunk
13:19
added some old dde snippets from Jun 2007 check-in: c9723faeb5 user: alex tags: trunk
13:12
drop ^@ in return values check-in: 4afcc3a70a user: alex tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Added dde/dde_col0_pipe.tcl.



















































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
#
# @(#)$Id: dde_col0_pipe.tcl,v 1.2 2007/05/15 08:38:12 alex Exp $
# (c) 2007 Alexander Schoepe
#

proc TkPresent {} {
  return [expr {![catch {package present Tk}]}]
}

if {[TkPresent]} {
  package require tile
  package require Tablelist_tile
}

package require msgcat
package require registry
package require dde

# -----------------------------------------------------------------------------

set setup(askquit) 1
set setup(command) {}
set setup(sep) |
set setup(len) 400

# -----------------------------------------------------------------------------

proc Slog { args } {
  #puts stderr $args
}

Slog starting

# -----------------------------------------------------------------------------

proc Exit { exitcode } {
  exit $exitcode
}

# -----------------------------------------------------------------------------

proc Quit { {choose _dialog} } {
  global setup

  switch -- $choose {
    _dialog {
      set w .quit
      if {[winfo exists $w]} {
        wm withdraw $w
        wm deiconify $w
        return
      }
      if {$setup(askquit)} {
        ttk::dialog $w -title [msgcat::mc Quit] -icon question \
          -message [msgcat::mc {Quit Program?}] \
          -detail [msgcat::mc {Do you wish to quit the Program?}] \
          -buttons [list no yes] \
          -labels [list no [msgcat::mc No] yes [msgcat::mc Yes]] \
          -command Quit
      } else {
        Quit yes
      }
    }
    yes {
      Exit 0
    }
    default {
    }
  }
}

# -----------------------------------------------------------------------------

proc TableColumnsSet { w list } {
  if {[winfo exists $w]} {
    foreach {tag data} $list {
      array set def $data
      if {[info exists def(def)]} {
        $w insertcolumns end [lindex $def(def) 0] [lrange $def(def) 1 end-1] [lindex $def(def) end]
        set col [expr {[$w columncount] - 1}]
        foreach {opt data} [array get def] {
          switch -- $opt {
            def {
              $w columnconfigure $col -name $tag
            }
            default {
              $w columnconfigure $col $opt $data
            }
          }
        }
      }
      unset def
    }
  }
}

# -----------------------------------------------------------------------------

proc SearchRegistry {} {
  global setup

  if {![catch {registry get HKEY_LOCAL_MACHINE\\SOFTWARE\\Classes\\.xls {}} class]} {
    if {![catch {registry get HKEY_LOCAL_MACHINE\\SOFTWARE\\Classes\\$class {}} type]} {
      if {![catch {registry get HKEY_LOCAL_MACHINE\\SOFTWARE\\Classes\\$class\\shell\\open\\command {}} setup(command)]} {
        set setup(command) [string map {\\ \\\\} $setup(command)]
      }
    }
  }
}

# -----------------------------------------------------------------------------

proc CheckForExcel {} {
  global setup

  set setup(excel) 0
  foreach list [dde services {} System] {
    if {[lindex $list 0] == "Excel"} {
      set setup(excel) 1
      break
    }
  }
  if {$setup(excel)} {
    set setup(status) "Excel is running."
    LookupExcelSheets
  } else {
    set setup(status) "Excel is not running!"
    $setup(lb,excel) delete 0 end
  }
}

# -----------------------------------------------------------------------------

proc LookupExcelSheets {} {
  global setup

  set lb $setup(lb,excel)
  $lb delete 0 end

  foreach item [dde request Excel System Topics] {
    if {[regexp {^\[(.+)(\.[Xx][Ll][Ss])\](.+)$} $item all file ext tab]} {
      $lb insert end [list $file$ext $tab $all]
    }
  }
}

# -----------------------------------------------------------------------------

proc DataWindow { topic data } {
  global artikel 
  global lno
  global msg

  set alert .msg_[clock seconds]_[clock clicks]
  ttk::dialog $alert -icon info -message [msgcat::mc {Please wait!}]\n\n[msgcat::mc {Getting Data ...}]
  update

  set tl .tl_[clock seconds]_[clock clicks]
  toplevel $tl
  wm title $tl $topic
  wm withdraw $tl

  set f $tl.f
  pack [ttk::frame $f -padding 3 -relief groove] -expand 1 -fill both
  grid columnconfigure $f 0 -weight 1
  grid rowconfigure $f 0 -weight 1

  set f $tl.f.t
  grid [ttk::frame $f -padding 3 -relief groove] -row 0 -column 0 -sticky wnes
  grid columnconfigure $f 0 -weight 1
  grid columnconfigure $f 1 -weight 0
  grid rowconfigure $f 0 -weight 1
  grid rowconfigure $f 1 -weight 0
  set lb $f.lb
  grid [tablelist::tablelist $lb -height 16 -width 40 -showseparators 1 -titlecolumns 0 -labelcommand tablelist::sortByColumn] -row 0 -column 0 -sticky nswe
  grid [ttk::scrollbar $f.sbv -orient vertical -command [list $lb yview] -takefocus 0] -row 0 -column 1 -sticky ns
  $lb configure -yscrollcommand "$f.sbv set"
  grid [ttk::scrollbar $f.sbh -orient horizontal -command [list $lb xview] -takefocus 0] -row 1 -column 0 -sticky we
  $lb configure -xscrollcommand "$f.sbh set"

  set f $tl.f.b
  grid [ttk::frame $f -padding 3 -relief groove] -row 1 -column 0 -sticky we
  grid columnconfigure $f 0 -weight 1
  grid [ttk::frame $f.f] -row 0 -column 0 -sticky wnes
  grid [ttk::button $f.nes -text [msgcat::mc {Table To Text}] -command "SaveData $lb"] -row 0 -column 1
  grid [ttk::button $f.c -text [msgcat::mc {Close}] -command "destroy $tl"] -row 0 -column 2

  TableColumnsSet $lb [subst {
      col0 {def {32 [msgcat::mc {Spalte 0}] right}}
  }]

  set lno 0
  foreach line [split $data \n] {
    if {$lno} {
      if {[string trim [set col0 [lindex $line 0]]] != ""} {
	$lb insert end [list $col0]
      }
    }
    incr lno
  }

  wm deiconify $tl
  focus -force $tl

  destroy $alert
}

# -----------------------------------------------------------------------------

proc SaveData { w } {
  global lno
  global msg
  global setup

  set data [$w get 0 end]
  $w delete 0 end

  set out {}
  set lno 1
  foreach line $data {
    lappend out $line
    incr lno
  }

  set file [tk_getSaveFile -parent . -title [msgcat::mc {Choose Text File}] -filetypes {{{Text Files} {.txt}}} -initialfile [msgcat::mc Untiteled].txt]
  if {![catch {open $file w} fd]} {
    set txt [join $out $setup(sep)]

    while {[string length $txt] > $setup(len)} {
      set pos [string last $setup(sep) $txt $setup(len)]
      if {$pos > -1} {
	incr pos -1
	set out [string range $txt 0 $pos]
	incr pos 2
	set txt [string range $txt $pos end]
	puts $fd $out
      } else {
	break
      }
    }
    if {[string length $txt] > 0} {
      puts $fd $txt
    }
    close $fd
  }
}

# -----------------------------------------------------------------------------

proc GetExcelSheet { W } {
  global setup

  if {[winfo class $W] == "Tablelist"} {
    set w $W
  } else {
    set w [tablelist::getTablelistPath $W]
  }

  if {[set sel [lindex [$w curselection] 0]] == ""} {
    return
  }

  foreach {dummy dummy topic} [$w get $sel] {}

  # max r 65536 c 256
  set rows 65536
  set cols 1

  if {[catch {string map {\r {} \" \\" ' \\' \{ ( \} )} [dde request Excel $topic Z1S1:Z${rows}S${cols}]} data] == 0} {
    DataWindow $topic $data
    unset data
  }
}

# -----------------------------------------------------------------------------

proc NewExcelSheet { w } {
  dde execute Excel System {[new(1)]}
  set topic [dde request Excel System "selection"] 
  set topic [string range $topic 0 [expr [string first "!" $topic]-1]]
  dde execute Excel $topic {[select("z1s1")]}
  clipboard clear 
  foreach line [$w get 0 end] {
    clipboard append [join $line \t]\n
  }
  dde execute Excel $topic {[paste()]}
}

# -----------------------------------------------------------------------------

proc StartExcel {} {
  global setup

  catch {eval exec $setup(command) &} rc
  CheckForExcel
}

# -----------------------------------------------------------------------------

proc Main {} {
  global setup

  wm title . {DDE Excel}
  wm protocol . WM_DELETE_WINDOW Quit

  set mb .menubar
  menu $mb
  . config -menu $mb

  set mn $mb.file
  $mb add cascade -label [msgcat::mc File] -menu $mn -underline 0
  menu $mn -tearoff 0

  $mn add command -label [msgcat::mc Quit] -underline 1 -state normal -command Quit -accelerator [msgcat::mc Ctrl]+q
  bind . <Control-Key-q> Quit

  set f .f
  pack [ttk::frame $f -padding 3 -relief groove] -expand 1 -fill both
  grid columnconfigure $f 0 -weight 1
  grid rowconfigure $f 1 -weight 1

  set f .f.t
  grid [ttk::frame $f -padding 3 -relief groove] -row 0 -column 0 -sticky we
  grid columnconfigure $f 1 -weight 1
  grid [ttk::label $f.l0 -text [msgcat::mc Status]] -row 0 -column 0
  grid [ttk::entry $f.e0 -textvariable setup(status) -width 16 -state readonly] -row 0 -column 1 -sticky we
  grid [ttk::label $f.l1 -text [msgcat::mc Command]] -row 1 -column 0
  grid [ttk::entry $f.e1 -textvariable setup(command) -width 64 -state readonly] -row 1 -column 1 -sticky we

  set f .f.e
  grid [ttk::frame $f -padding 3 -relief groove] -row 1 -column 0 -sticky we
  grid columnconfigure $f 4 -weight 1
  grid [ttk::label $f.l0 -text [msgcat::mc Separator]] -row 0 -column 0
  grid [ttk::entry $f.e0 -textvariable setup(sep) -width 1] -row 0 -column 1 -sticky we
  grid [ttk::label $f.l1 -text [msgcat::mc Length]] -row 0 -column 2
  grid [ttk::entry $f.e1 -textvariable setup(len) -width 6] -row 0 -column 3 -sticky we
  grid [ttk::frame $f.f] -row 0 -column 4 -sticky we


  set f .f.m
  grid [ttk::frame $f -padding 3 -relief groove] -row 2 -column 0 -sticky wnes
  grid columnconfigure $f 0 -weight 1
  grid columnconfigure $f 1 -weight 0
  grid rowconfigure $f 0 -weight 1
  grid rowconfigure $f 1 -weight 0
  set lb $f.lb
  grid [tablelist::tablelist $lb -height 24 -width 60 -showseparators 1 -titlecolumns 2 -labelcommand tablelist::sortByColumn] -row 0 -column 0 -sticky nswe
  grid [ttk::scrollbar $f.sbv -orient vertical -command [list $lb yview] -takefocus 0] -row 0 -column 1 -sticky ns
  $lb configure -yscrollcommand "$f.sbv set"
  grid [ttk::scrollbar $f.sbh -orient horizontal -command [list $lb xview] -takefocus 0] -row 1 -column 0 -sticky we
  $lb configure -xscrollcommand "$f.sbh set"

  set f .f.b
  grid [ttk::frame $f -padding 3 -relief groove] -row 3 -column 0 -sticky we
  grid columnconfigure $f 0 -weight 1
  grid [ttk::frame $f.f] -row 0 -column 0 -sticky wnes
  grid [ttk::button $f.se -text [msgcat::mc {Start Excel}] -command StartExcel] -row 0 -column 1
  grid [ttk::button $f.les -text [msgcat::mc {Lookup Excel Sheets}] -command CheckForExcel] -row 0 -column 2

  TableColumnsSet $lb [subst {
    book {def {20 [msgcat::mc {Book}] left}}
    sheet {def {20 [msgcat::mc {Sheet}] left} -stretchable 1}
    topic {def {32 [msgcat::mc {Topic}] left} -hide 0}
  }]
  bind [$lb bodytag] <Double-1> "GetExcelSheet %W"

  set setup(lb,excel) $lb

  focus -force .
}

# -----------------------------------------------------------------------------

Main
SearchRegistry
CheckForExcel

Added dde/outlook_export_contacts.tcl.





























































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
package require tcom

set path {C:\Dokumente und Einstellungen\alex\Desktop\outlook}

# http://msdn2.microsoft.com/en-us/library/aa219371(office.11).aspx

proc BuildArray { v l } {
  upvar #0 $v my
  foreach {a b} $l {
    set my($a) $b
    set my($b) $a
  }
}

BuildArray olSaveAsType {
  olDoc 4
  olHTML 5
  olICal 8
  olMSG 3
  olMSGUnicode 9
  olRTF 1
  olTemplate 2
  olTXT 0
  olVCal 7
  olVCard 6
}

BuildArray olItemType {
  olAppointmentItem 1
  olContactItem 2
  olDistributionListItem 7
  olJournalItem 4
  olMailItem 0
  olNoteItem 5
  olPostItem 6
  olTaskItem 3
}

BuildArray olDefaultFolders {
  olFolderCalendar 9
  olFolderContacts 10
  olFolderDeletedItems 3
  olFolderDrafts 16
  olFolderInbox 6
  olFolderJournal 11
  olFolderJunk 23
  olFolderNotes 12
  olFolderOutbox 4
  olFolderSentMail 5
  olFolderTasks 13
  olPublicFoldersAllPublicFolders 18
  olFolderConflicts 19
  olFolderLocalFailures 21
  olFolderServerFailures 22
  olFolderSyncIssues 20
}

BuildArray olObjectClass {
  olAction 32
  olActions 33
  olAddressEntries 21
  olAddressEntry 8
  olAddressList 7
  olAddressLists 20
  olApplication 0
  olAppointment 26
  olAttachment 5
  olAttachments 18
  olConflict 117
  olConflicts 118
  olContact 40
  olDistributionList 69
  olDocument 41
  olException 30
  olExceptions 29
  olExplorer 34
  olExplorers 60
  olFolder 2
  olFolders 15
  olFormDescription 37
  olInspector 35
  olInspectors 61
  olItemProperties 98
  olItemProperty 99
  olItems 16
  olJournal 42
  olLink 75
  olLinks 76
  olMail 43
  olMeetingCancellation 54
  olMeetingRequest 53
  olMeetingResponseNegative 55
  olMeetingResponsePositive 56
  olMeetingResponseTentative 57
  olNamespace 1
  olNote 44
  olOutlookBarGroup 66
  olOutlookBarGroups 65
  olOutlookBarPane 63
  olOutlookBarShortcut 68
  olOutlookBarShortcuts 67
  olOutlookBarStorage 64
  olPages 36
  olPanes 62
  olPost 45
  olPropertyPages 71
  olPropertyPageSite 70
  olRecipient 4
  olRecipients 17
  olRecurrencePattern 28
  olReminder 101
  olReminders 100
  olRemote 47
  olReport 46
  olResults 78
  olSearch 77
  olSelection 74
  olSyncObject 72
  olSyncObjects 73
  olTask 48
  olTaskRequest 49
  olTaskRequestAccept 51
  olTaskRequestDecline 52
  olTaskRequestUpdate 50
  olUserProperties 38
  olUserProperty 39
  olView 80
  olViews 79
}

proc ProcessItems { obj } {

  set iobj [$obj Items]
  set icount [$iobj Count]

  puts icount=$icount

  for {set i 1} {$i <= $icount} {incr i} {
    set item [$iobj Item $i]
    set fn [$item FullName]
    if {[string trim $fn] == ""} {
      set fn [$item CompanyName]
      if {[string trim $fn] == ""} {
	set fn $i
      }
    }
    set fn [string map {/ _} $fn]
    $item SaveAs [file join $::path ${fn}.vcf] $::olSaveAsType(olVCard)
  }
}

file mkdir $path

set com(ol) [::tcom::ref createobject "Outlook.Application"]
set com(ol,session) [$com(ol) Session]
set com(ol,contactsFolder) [$com(ol,session) GetDefaultFolder $olDefaultFolders(olFolderContacts)]
ProcessItems $com(ol,contactsFolder)

if 0 {
package require tcom
set com(ol) [::tcom::ref createobject "Outlook.Application"]
set com(ol,session) [$com(ol) Session]
set com(ol,contactsFolder) [$com(ol,session) GetDefaultFolder 10]
set items [$com(ol,contactsFolder) Items]
set item [$items Item 1]
set itemprop [$item ItemProperties]
set count [$itemprop Count]
for {set i 0} {$i <= $count} {incr i} {
  set prop [$itemprop Item $i]
  puts ---$i---
  puts n=[$prop Name]
  puts v=[$prop Value]
}
}

Added dde/outlook_export_test.tcl.









































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
package require tcom

# http://msdn2.microsoft.com/en-us/library/aa219371(office.11).aspx

proc BuildArray { v l } {
  upvar #0 $v my
  foreach {a b} $l {
    set my($a) $b
    set my($b) $a
  }
}

BuildArray olSaveAsType {
  olDoc 4
  olHTML 5
  olICal 8
  olMSG 3
  olMSGUnicode 9
  olRTF 1
  olTemplate 2
  olTXT 0
  olVCal 7
  olVCard 6
}

BuildArray olItemType {
  olAppointmentItem 1
  olContactItem 2
  olDistributionListItem 7
  olJournalItem 4
  olMailItem 0
  olNoteItem 5
  olPostItem 6
  olTaskItem 3
}

BuildArray olDefaultFolders {
  olFolderCalendar 9
  olFolderContacts 10
  olFolderDeletedItems 3
  olFolderDrafts 16
  olFolderInbox 6
  olFolderJournal 11
  olFolderJunk 23
  olFolderNotes 12
  olFolderOutbox 4
  olFolderSentMail 5
  olFolderTasks 13
  olPublicFoldersAllPublicFolders 18
  olFolderConflicts 19
  olFolderLocalFailures 21
  olFolderServerFailures 22
  olFolderSyncIssues 20
}

BuildArray olObjectClass {
  olAction 32
  olActions 33
  olAddressEntries 21
  olAddressEntry 8
  olAddressList 7
  olAddressLists 20
  olApplication 0
  olAppointment 26
  olAttachment 5
  olAttachments 18
  olConflict 117
  olConflicts 118
  olContact 40
  olDistributionList 69
  olDocument 41
  olException 30
  olExceptions 29
  olExplorer 34
  olExplorers 60
  olFolder 2
  olFolders 15
  olFormDescription 37
  olInspector 35
  olInspectors 61
  olItemProperties 98
  olItemProperty 99
  olItems 16
  olJournal 42
  olLink 75
  olLinks 76
  olMail 43
  olMeetingCancellation 54
  olMeetingRequest 53
  olMeetingResponseNegative 55
  olMeetingResponsePositive 56
  olMeetingResponseTentative 57
  olNamespace 1
  olNote 44
  olOutlookBarGroup 66
  olOutlookBarGroups 65
  olOutlookBarPane 63
  olOutlookBarShortcut 68
  olOutlookBarShortcuts 67
  olOutlookBarStorage 64
  olPages 36
  olPanes 62
  olPost 45
  olPropertyPages 71
  olPropertyPageSite 70
  olRecipient 4
  olRecipients 17
  olRecurrencePattern 28
  olReminder 101
  olReminders 100
  olRemote 47
  olReport 46
  olResults 78
  olSearch 77
  olSelection 74
  olSyncObject 72
  olSyncObjects 73
  olTask 48
  olTaskRequest 49
  olTaskRequestAccept 51
  olTaskRequestDecline 52
  olTaskRequestUpdate 50
  olUserProperties 38
  olUserProperty 39
  olView 80
  olViews 79
}

set com(ol) [::tcom::ref createobject "Outlook.Application"]
set com(ol,session) [$com(ol) Session]
set com(ol,contactsFolder) [$com(ol,session) GetDefaultFolder $olDefaultFolders(olFolderContacts)]

set items [$com(ol,contactsFolder) Items]
set ic [$items Count]

for {set c 1} {$c <= $ic} {incr c} {
  puts stderr $c
  puts --------------------------------------------------------------------
  set item [$items Item $c]
  set itemprop [$item ItemProperties]

  set ipc [$itemprop Count]
  for {set i 0} {$i < $ipc} {incr i} {
    set prop [$itemprop Item $i]
    puts n=[$prop Name]
    puts v=[$prop Value]
  }
}

Added dde/outlook_tree_view.tcl.







































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
package require tcom

# http://msdn2.microsoft.com/en-us/library/aa219371(office.11).aspx

proc BuildArray { v l } {
  upvar #0 $v my
  foreach {a b} $l {
    set my($a) $b
    set my($b) $a
  }
}

BuildArray olSaveAsType {
  olDoc 4
  olHTML 5
  olICal 8
  olMSG 3
  olMSGUnicode 9
  olRTF 1
  olTemplate 2
  olTXT 0
  olVCal 7
  olVCard 6
}

BuildArray olItemType {
  olAppointmentItem 1
  olContactItem 2
  olDistributionListItem 7
  olJournalItem 4
  olMailItem 0
  olNoteItem 5
  olPostItem 6
  olTaskItem 3
}

BuildArray olDefaultFolders {
  olFolderCalendar 9
  olFolderContacts 10
  olFolderDeletedItems 3
  olFolderDrafts 16
  olFolderInbox 6
  olFolderJournal 11
  olFolderJunk 23
  olFolderNotes 12
  olFolderOutbox 4
  olFolderSentMail 5
  olFolderTasks 13
  olPublicFoldersAllPublicFolders 18
  olFolderConflicts 19
  olFolderLocalFailures 21
  olFolderServerFailures 22
  olFolderSyncIssues 20
}

BuildArray olObjectClass {
  olAction 32
  olActions 33
  olAddressEntries 21
  olAddressEntry 8
  olAddressList 7
  olAddressLists 20
  olApplication 0
  olAppointment 26
  olAttachment 5
  olAttachments 18
  olConflict 117
  olConflicts 118
  olContact 40
  olDistributionList 69
  olDocument 41
  olException 30
  olExceptions 29
  olExplorer 34
  olExplorers 60
  olFolder 2
  olFolders 15
  olFormDescription 37
  olInspector 35
  olInspectors 61
  olItemProperties 98
  olItemProperty 99
  olItems 16
  olJournal 42
  olLink 75
  olLinks 76
  olMail 43
  olMeetingCancellation 54
  olMeetingRequest 53
  olMeetingResponseNegative 55
  olMeetingResponsePositive 56
  olMeetingResponseTentative 57
  olNamespace 1
  olNote 44
  olOutlookBarGroup 66
  olOutlookBarGroups 65
  olOutlookBarPane 63
  olOutlookBarShortcut 68
  olOutlookBarShortcuts 67
  olOutlookBarStorage 64
  olPages 36
  olPanes 62
  olPost 45
  olPropertyPages 71
  olPropertyPageSite 70
  olRecipient 4
  olRecipients 17
  olRecurrencePattern 28
  olReminder 101
  olReminders 100
  olRemote 47
  olReport 46
  olResults 78
  olSearch 77
  olSelection 74
  olSyncObject 72
  olSyncObjects 73
  olTask 48
  olTaskRequest 49
  olTaskRequestAccept 51
  olTaskRequestDecline 52
  olTaskRequestUpdate 50
  olUserProperties 38
  olUserProperty 39
  olView 80
  olViews 79
}

proc ProcessItems { obj { l 0 } } {
  set sep [string repeat { } [expr {$l * 2}]]

  puts ${sep}---$l---

  set iobj [$obj Items]
  set icount [$iobj Count]

  puts ${sep}icount=$icount

  #for {set i 1} {$i <= $icount} {incr i} {
  #  set item [$iobj Item $i]
  #  set class [$item Class]
  #}
    set item [$iobj Item 1]
    set class [$item Class]
    puts ${sep}class=$class-$::olObjectClass($class)
    #catch {
    #  set type [$obj Type]
    #  puts ${sep}type=$type-$::olItemType($type)
    #}
}

proc ProcessFolder { obj { l 0 } } {
  set sep [string repeat { } [expr {$l * 2}]]

  puts ${sep}---$l---

  set fobj [$obj Folders]
  set fcount [$fobj Count]

  puts ${sep}fcount=$fcount

  for {set i 1} {$i <= $fcount} {incr i} {
    puts ${sep}-$i-

    set fitem [$fobj Item $i]
    set fname [$fitem Name]
    set ffpath [$fitem FullFolderPath]

    puts ${sep}fname=$fname
    puts ${sep}ffpath=$ffpath

    set sfolders [$fitem Folders]
    set sfcount [$sfolders Count]

    puts ${sep}sfcount=$sfcount

    set items [$fitem Items]
    set icount [$items Count]

    puts ${sep}icount=$icount

    if {$icount > 0} {
      ProcessItems $fitem [expr {$l + 1}]
    }

    if {$sfcount > 0} {
      ProcessFolder $fitem [expr {$l + 1}]
    }
  }
}

set ::com(ol) [::tcom::ref createobject "Outlook.Application"]

ProcessFolder [$::com(ol) Session]