-
Notifications
You must be signed in to change notification settings - Fork 1
/
outlook_windows.go
34 lines (28 loc) · 1.04 KB
/
outlook_windows.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
30
31
32
33
34
// +build windows
package main
import (
"time"
ole "github.com/go-ole/go-ole"
"github.com/go-ole/go-ole/oleutil"
)
func goToDate(dateToGo time.Time) {
date := dateToGo.Format("02/01/2006")
ole.CoInitialize(0)
defer ole.CoUninitialize()
unknown, _ := oleutil.CreateObject("Outlook.Application")
defer unknown.Release()
outlook, _ := unknown.QueryInterface(ole.IID_IDispatch)
defer outlook.Release()
ns := oleutil.MustCallMethod(outlook, "GetNamespace", "MAPI").ToIDispatch()
calendar := oleutil.MustCallMethod(ns, "GetDefaultFolder", 9).ToIDispatch()
explorer := oleutil.MustCallMethod(outlook, "ActiveExplorer").ToIDispatch()
if explorer == nil {
// Start outlook if not started
oleutil.MustCallMethod(calendar, "Display")
explorer = oleutil.MustCallMethod(outlook, "ActiveExplorer").ToIDispatch()
}
oleutil.MustCallMethod(explorer, "CurrentFolder", calendar)
view := oleutil.MustGetProperty(explorer, "CurrentView").ToIDispatch()
oleutil.MustCallMethod(view, "GoToDate", date).ToIDispatch()
oleutil.MustCallMethod(explorer, "Activate")
}