-
Notifications
You must be signed in to change notification settings - Fork 0
/
outlook.go
29 lines (25 loc) · 965 Bytes
/
outlook.go
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
// +build windows
package main
import (
"fmt"
ole "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/go-ole/go-ole"
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/go-ole/go-ole/oleutil"
)
func main() {
ole.CoInitialize(0)
unknown, _ := oleutil.CreateObject("Outlook.Application")
outlook, _ := unknown.QueryInterface(ole.IID_IDispatch)
ns := oleutil.MustCallMethod(outlook, "GetNamespace", "MAPI").ToIDispatch()
folder := oleutil.MustCallMethod(ns, "GetDefaultFolder", 10).ToIDispatch()
contacts := oleutil.MustCallMethod(folder, "Items").ToIDispatch()
count := oleutil.MustGetProperty(contacts, "Count").Value().(int32)
for i := 1; i <= int(count); i++ {
item, err := oleutil.GetProperty(contacts, "Item", i)
if err == nil && item.VT == ole.VT_DISPATCH {
if value, err := oleutil.GetProperty(item.ToIDispatch(), "FullName"); err == nil {
fmt.Println(value.Value())
}
}
}
oleutil.MustCallMethod(outlook, "Quit")
}